Skip to content

Commit

Permalink
backend: Update Make file to use docker compose for tests
Browse files Browse the repository at this point in the history
This patch updates the make file to use the docker compose
file for tests instead of the shell scripts and docker
commands.

Signed-off-by: Santhosh Nagaraj S <[email protected]>
  • Loading branch information
yolossn committed Jan 11, 2022
1 parent bbd0394 commit d5dc961
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
21 changes: 10 additions & 11 deletions backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@ coverage.out: check-code-coverage
check-code-coverage:
go test -p 1 -coverprofile=coverage.out ./...

container_id:
./tools/setup_local_db.sh \
--id-file container_id.tmp \
--db-name nebraska_tests \
--password nebraska \
--pg-version 13.3
mv container_id.tmp container_id
.PHONY: test-service-up
test-service-up:
docker compose -f ./docker-compose.test.yaml up -d

.PHONY: test-service-down
test-service-down:
docker compose -f ./docker-compose.test.yaml down

.PHONY: check-backend-with-container
check-backend-with-container: container_id
set -e; \
trap "$(DOCKER_CMD) kill $$(cat container_id); $(DOCKER_CMD) rm $$(cat container_id); rm -f container_id" EXIT; \
go test -p 1 ./...
check-backend-with-container: test-service-up
go clean -testcache && go test -p 1 ./...
$(MAKE) test-service-down

run: bin/nebraska
./bin/nebraska -auth-mode noop -debug
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:

server:
build:
context: ../../../
context: ../
dockerfile: Dockerfile
ports:
- "8000:8000"
Expand Down

0 comments on commit d5dc961

Please sign in to comment.