diff --git a/.gitignore b/.gitignore index b1630ac..d119013 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,7 @@ dist/ # Built executable restic-scheduler data/ + +# Itest temp dirs +itest/data +itest/repo diff --git a/Makefile b/Makefile index 4815a9b..36e84c6 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,10 @@ test: go test -v -coverprofile=coverage.out # -short go tool cover -func=coverage.out +.PHONY: itest +itest: docker-build + ./itest/run.sh + # Installs pre-commit hooks .PHONY: install-hooks install-hooks: diff --git a/itest/bootstrap-tests.sh b/itest/bootstrap-tests.sh new file mode 100755 index 0000000..e4dbf64 --- /dev/null +++ b/itest/bootstrap-tests.sh @@ -0,0 +1,31 @@ +#! /bin/sh +set -ex + +# Create flat file +echo "Hello" > /data/test.txt + +# Create Sqlite database +touch /data/test_database.db +sqlite3 /data/test_database.db <<-EOF +CREATE TABLE test_table ( + id integer PRIMARY KEY, + data text NOT NULL +); + +INSERT INTO test_table(data) +VALUES ("Test row"); +EOF + +# Create MySql database +until mysql --host "$MYSQL_HOST" --user "$MYSQL_USER" --password="$MYSQL_PWD" --execute "SHOW DATABASES;"; do + sleep 1 +done +mysql --host "$MYSQL_HOST" --user "$MYSQL_USER" --password="$MYSQL_PWD" main <