-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add some tests and launch them in docker instead of runner host
- Loading branch information
Showing
19 changed files
with
362 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
disable=SC1090 | ||
disable=SC1090,SC2012 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
all: test build | ||
all: test | ||
|
||
.PHONY: test | ||
test: | ||
@for file in $$(find src -type f); do shellcheck --format=tty $$file; done; | ||
@sudo ./test/bats/bin/bats test/unit | ||
|
||
.PHONY: build | ||
build: | ||
docker build -t williarin/secure-mysql-backups:latest --target base . | ||
@for file in $$(find ./src -type f); do shellcheck -e 1091,2012 --format=tty $$file; done; | ||
@./test/bats/bin/bats test/unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Docker Compose file for executing test suite | ||
|
||
version: '3.8' | ||
|
||
services: | ||
database: | ||
image: mysql:8 | ||
restart: 'no' | ||
environment: | ||
- MYSQL_DATABASE=my_db | ||
- MYSQL_ROOT_PASSWORD=root | ||
|
||
backup: | ||
build: | ||
context: . | ||
target: test | ||
restart: 'no' | ||
depends_on: | ||
- database |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
setup() { | ||
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" | ||
PATH="$DIR/../../src:$DIR/../../src/lib:$PATH" | ||
source db.sh | ||
|
||
wait_for_database "database" "3306" "root" "root" "60" | ||
} | ||
|
||
teardown() { | ||
run bash -c "rm -f /tmp/backup/*" | ||
} | ||
|
||
@test "fails if no argument given" { | ||
run dump_database | ||
[ "$status" -eq 1 ] | ||
[ "$output" = "5 arguments required, 0 provided" ] | ||
} | ||
|
||
@test "dumps a database" { | ||
run dump_database "database" "3306" "root" "root" "my_db" | ||
[ "$status" -eq 0 ] | ||
[ -f "/tmp/backup/my_db.sql" ] | ||
[[ "$(head -n1 "/tmp/backup/my_db.sql")" = *"-- MariaDB dump"* ]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.