Skip to content

Commit

Permalink
Introduce test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
m110 committed Jan 28, 2021
1 parent 6954ccb commit 0e3e9d8
Show file tree
Hide file tree
Showing 37 changed files with 2,740 additions and 145 deletions.
5 changes: 5 additions & 0 deletions .e2e.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TRAINER_HTTP_ADDR=localhost:3000
TRAINER_GRPC_ADDR=localhost:3010
TRAININGS_HTTP_ADDR=localhost:3001
USERS_GRPC_ADDR=localhost:3020
USERS_HTTP_ADDR=localhost:3002
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ MYSQL_ADDR=localhost
MYSQL_DATABASE=db
MYSQL_USER=user
MYSQL_PASSWORD=password
MYSQL_RANDOM_ROOT_PASSWORD=true
MYSQL_RANDOM_ROOT_PASSWORD=true
8 changes: 7 additions & 1 deletion .test.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
FIRESTORE_EMULATOR_HOST=localhost:8787
FIRESTORE_EMULATOR_HOST=localhost:8788
MYSQL_ADDR=localhost

TRAINER_HTTP_ADDR=localhost:5000
TRAINER_GRPC_ADDR=localhost:5010
TRAININGS_HTTP_ADDR=localhost:5001
USERS_HTTP_ADDR=localhost:5002
USERS_GRPC_ADDR=localhost:5020
23 changes: 11 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
include .env
include .test.env
export

.PHONY: openapi
Expand All @@ -9,12 +8,18 @@ openapi: openapi_http openapi_js
openapi_http:
oapi-codegen -generate types -o internal/trainings/ports/openapi_types.gen.go -package ports api/openapi/trainings.yml
oapi-codegen -generate chi-server -o internal/trainings/ports/openapi_api.gen.go -package ports api/openapi/trainings.yml
oapi-codegen -generate types -o internal/common/client/trainings/openapi_types.gen.go -package trainings api/openapi/trainings.yml
oapi-codegen -generate client -o internal/common/client/trainings/openapi_client_gen.go -package trainings api/openapi/trainings.yml

oapi-codegen -generate types -o internal/trainer/ports/openapi_types.gen.go -package ports api/openapi/trainer.yml
oapi-codegen -generate chi-server -o internal/trainer/ports/openapi_api.gen.go -package ports api/openapi/trainer.yml
oapi-codegen -generate types -o internal/common/client/trainer/openapi_types.gen.go -package trainer api/openapi/trainer.yml
oapi-codegen -generate client -o internal/common/client/trainer/openapi_client_gen.go -package trainer api/openapi/trainer.yml

oapi-codegen -generate types -o internal/users/openapi_types.gen.go -package main api/openapi/users.yml
oapi-codegen -generate chi-server -o internal/users/openapi_api.gen.go -package main api/openapi/users.yml
oapi-codegen -generate types -o internal/common/client/users/openapi_types.gen.go -package users api/openapi/users.yml
oapi-codegen -generate client -o internal/common/client/users/openapi_client_gen.go -package users api/openapi/users.yml

.PHONY: openapi_js
openapi_js:
Expand Down Expand Up @@ -52,14 +57,8 @@ fmt:
mycli:
mycli -u ${MYSQL_USER} -p ${MYSQL_PASSWORD} ${MYSQL_DATABASE}

INERNAL_PACKAGES := $(wildcard internal/*)

ifeq (test,$(firstword $(MAKECMDGOALS)))
TEST_ARGS := $(subst $$,$$$$,$(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)))
$(eval $(TEST_ARGS):;@:)
endif

.PHONY: test $(INERNAL_PACKAGES)
test: $(INERNAL_PACKAGES)
$(INERNAL_PACKAGES):
@(cd $@ && go test -count=1 -race ./... $(subst $$$$,$$,$(TEST_ARGS)))
test:
@./scripts/test.sh common .e2e.env
@./scripts/test.sh trainer .test.env
@./scripts/test.sh trainings .test.env
@./scripts/test.sh users .test.env
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ services:
- "127.0.0.1:4000:4000"
restart: unless-stopped

firestore-component-tests:
image: karhoo/firestore-emulator:0.3.2
env_file:
- .env
ports:
- "127.0.0.1:8788:8787"
restart: unless-stopped

mysql:
image: mysql:8
env_file:
Expand Down
Loading

0 comments on commit 0e3e9d8

Please sign in to comment.