Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(tests): add install tests
  • Loading branch information
Airscript committed Aug 14, 2022
commit 0590c97e96435dfcc8b65e5527e36039b81b9d75
File renamed without changes.
2 changes: 1 addition & 1 deletion .docker/blog.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ ENTRYPOINT ["./scripts/docker-entrypoint.sh"]

CMD ["hugo"]

EXPOSE ${BLOG_PORT}
EXPOSE ${BLOG_PORT}
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,28 @@ all-test: build-test run-test

.PHONY: clean-test
clean-test:
docker rmi airscript/bats
docker rm worker-bats-node; \
docker rm worker-bats-alpine; \
docker rmi airscript/bats:node; \
docker rmi airscript/bats:alpine

.PHONY: clean-bats
clean-bats:
docker rmi bats/bats:1.7.0
docker rmi node:18.7.0-alpine3.16

.PHONY: build-test
build-test:
docker build -f .docker/bats.Dockerfile -t airscript/bats .
docker build -f .docker/bats.alpine.Dockerfile -t airscript/bats:alpine .
docker build -f .docker/bats.node.Dockerfile -t airscript/bats:node .

.PHONY: run-test
run-test:
docker run -it --name="worker-bats" airscript/bats ./tests
docker rm worker-bats
docker run -it --rm --name="worker-bats-alpine" airscript/bats:alpine \
./tests/_.bats ./tests/install.bats ./tests/shared.bats

docker run -it --rm --name="worker-bats-node" airscript/bats:node \
./tests/_.bats ./tests/install-npm.bats

.PHONY: install-bash
install-bash:
Expand Down
4 changes: 4 additions & 0 deletions scripts/install/git.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/bash
if [ ! "$1" = "compose" ]; then
apk add git
echo "Git installed successfully."

else
echo "Git installation has been skipped."
fi
1 change: 1 addition & 0 deletions scripts/install/hugo.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
apk add hugo
echo "Hugo installed successfully."
1 change: 1 addition & 0 deletions scripts/install/make.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/bash
apk add make
echo "Make installed successfully."
26 changes: 26 additions & 0 deletions tests/install.bats
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,30 @@ setup() {
run ./scripts/install/docker-cli.sh
assert_output --partial "$INSTALL_DOCKER_CLI"
refute_output --partial "ERROR"
}

@test "Install Git" {
run ./scripts/install/git.sh
assert_output --partial "$INSTALL_GIT"
refute_output --partial "ERROR"
refute_output --partial "$SKIP_INSTALL_GIT"
}

@test "Skip install Git" {
run ./scripts/install/git.sh compose
assert_output --partial "$SKIP_INSTALL_GIT"
refute_output --partial "ERROR"
refute_output --partial "$INSTALL_GIT"
}

@test "Install Hugo" {
run ./scripts/install/hugo.sh
assert_output --partial "$INSTALL_HUGO"
refute_output --partial "ERROR"
}

@test "Install Make" {
run ./scripts/install/make.sh
assert_output --partial "$INSTALL_MAKE"
refute_output --partial "ERROR"
}
1 change: 1 addition & 0 deletions tests/libraries/bats-assert
Submodule bats-assert added at ffe84e
1 change: 1 addition & 0 deletions tests/libraries/bats-support
Submodule bats-support added at 3c8fad
6 changes: 6 additions & 0 deletions tests/mocks.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash
readonly INSTALL_NPM="npm installed successfully."
readonly INSTALL_GIT="Git installed successfully."
readonly INSTALL_HUGO="Hugo installed successfully."
readonly INSTALL_MAKE="Make installed successfully."
readonly INSTALL_BASH="Bash installed successfully."
readonly SKIP_INSTALL_GIT="Git installation has been skipped."
readonly INSTALL_DOCKER_CLI="Docker CLI installed successfully."
readonly INSTALL_NETLIFY_CLI="Netlify CLI installed successfully."
readonly ADD_GIT_SUBMODULE_SKIPPED="Git submodule update skipped."
readonly ADD_GIT_SUBMODULE_EXECUTED="Git submodule update executed."