diff --git a/Makefile b/Makefile index e7a0ddce9ac694f39aa34c0e602717bd1d02b9bd..d5344941faf10788f62bd607b4d25d09f11dc673 100644 --- a/Makefile +++ b/Makefile @@ -32,5 +32,11 @@ stop: # stop container version: # print current component version @echo ${FAAS_DB_VERSION} +test: testFaasDB # run all tests + +testFaasDB: # run checking docker image tests + @echo "# run test version" + bats test/faas-db-tests.bats + help: # this help @awk 'BEGIN {FS = ":.*?# "} /^[a-zA-Z_-]+:.*?# / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) diff --git a/README.md b/README.md index 9c6fca519d90179e2ad8401af7dbf281f2a63be3..4082da8924131bf3ef96617209a81b9a85b988e8 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ ## structure `_conf/`_ - directory with configuration files +`test/` - directory with tests files ## build image To build `faas-db` docker image @@ -26,4 +27,6 @@ up build and run container logs print docker logs stop stop container version print current component version +test run all tests +testFaasDB run checking docker image tests ` diff --git a/test/faas-db-tests.bats b/test/faas-db-tests.bats new file mode 100644 index 0000000000000000000000000000000000000000..41313a4b0d1d071dd884b8f64c50828051de08c9 --- /dev/null +++ b/test/faas-db-tests.bats @@ -0,0 +1,38 @@ +#! /usr/bin/env bats + +@test "faas-db - checking version in variables" { + [ $FAAS_DB_VERSION = "1.0-SNAPSHOT" ] +} + +@test "faas-db - checking app name in variables" { + [ $FAAS_DB_NAME = "faas-db" ] +} + +@test "faas-db - checking image string in variables" { + [ $FAAS_DB_IMAGE = "faas/faas-db:1.0-SNAPSHOT" ] +} + +@test "faas-db - checking version in image file" { + run docker exec $FAAS_DB_NAME bash -c 'cat /faas-docker-version' + [ "$output" = "1.0-SNAPSHOT" ] +} + +@test "faas-db - checking app name in image file" { + run docker exec $FAAS_DB_NAME bash -c 'cat /faas-docker-name' + [ "$output" = "faas-db" ] +} + +@test "faas-db - checking image string in image file" { + run docker exec $FAAS_DB_NAME bash -c 'cat /faas-docker-image' + [ "$output" = "faas/faas-db:1.0-SNAPSHOT" ] +} + +@test "faas-db - checking DB version in client command" { + run docker exec $FAAS_DB_NAME bash -c 'mysql --version' + [ "$output" = "mysql Ver 15.1 Distrib 10.5.8-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2" ] +} + +@test "faas-db - checking DB version in running DB instance" { + run docker exec $FAAS_DB_NAME bash -c "mysql --disable-column-names -uroot -p${MYSQL_ROOT_PASSWORD} mysql -e 'select version();'" + [ "$output" = "10.5.8-MariaDB-1:10.5.8+maria~focal" ] +}