Automates DB reset and migrations when unit and integration tests are run
This commit is contained in:
@@ -41,16 +41,34 @@ metalint: | $(METALINT)
|
||||
lint:
|
||||
$(LINT) $$($(PKGS)) | grep -v -E "exported (function)|(var)|(method)|(type).*should have comment or be unexported"
|
||||
|
||||
#Test
|
||||
TEST_DB = vulcanize_testing
|
||||
TEST_CONNECT_STRING = postgresql://localhost:5432/$(TEST_DB)?sslmode=disable
|
||||
|
||||
.PHONY: test
|
||||
test: | $(GINKGO) $(LINT)
|
||||
go vet ./...
|
||||
go fmt ./...
|
||||
dropdb --if-exists $(TEST_DB)
|
||||
createdb $(TEST_DB)
|
||||
cd db/migrations;\
|
||||
$(GOOSE) postgres "$(TEST_CONNECT_STRING)" up
|
||||
cd db/migrations/;\
|
||||
$(GOOSE) postgres "$(TEST_CONNECT_STRING)" reset
|
||||
make migrate NAME=$(TEST_DB)
|
||||
$(GINKGO) -r --skipPackage=integration_tests,integration
|
||||
|
||||
.PHONY: integrationtest
|
||||
integrationtest: | $(GINKGO) $(LINT)
|
||||
go vet ./...
|
||||
go fmt ./...
|
||||
dropdb --if-exists $(TEST_DB)
|
||||
createdb $(TEST_DB)
|
||||
cd db/migrations;\
|
||||
$(GOOSE) postgres "$(TEST_CONNECT_STRING)" up
|
||||
cd db/migrations/;\
|
||||
$(GOOSE) postgres "$(TEST_CONNECT_STRING)" reset
|
||||
make migrate NAME=$(TEST_DB)
|
||||
$(GINKGO) -r integration_test/
|
||||
|
||||
build:
|
||||
@@ -71,7 +89,6 @@ checkdbvars:
|
||||
test -n "$(HOST_NAME)" # $$HOST_NAME
|
||||
test -n "$(PORT)" # $$PORT
|
||||
test -n "$(NAME)" # $$NAME
|
||||
test -n "$(USER)" # $$USER
|
||||
@echo $(CONNECT_STRING)
|
||||
|
||||
## Check that the migration variable (id/timestamp) is provided
|
||||
|
||||
Reference in New Issue
Block a user