diff --git a/Makefile b/Makefile index 2c91cbcc3d..4e4893f381 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,19 @@ +.PHONY: build test test-examples regen + build: go build ./... test: go test ./... +test-examples: + go test --tags=examples ./... + +regen: sqlc-dev + go run ./scripts/regenerate/ + sqlc-dev: go build -o ~/bin/sqlc-dev ./cmd/sqlc/ sqlc-pg-gen: go build -o ~/bin/sqlc-pg-gen ./internal/tools/sqlc-pg-gen - -regen: sqlc-dev - go run ./scripts/regenerate/ diff --git a/README.md b/README.md index 81d9c3074a..4c9c35cf37 100644 --- a/README.md +++ b/README.md @@ -471,15 +471,24 @@ go build -o ~/go/bin/sqlc-dev ./cmd/sqlc ### Running Tests -To run the tests, include the `exp` tag. Without this tag, a few tests will -fail. +``` +go test ./... +``` + +To run the tests in the examples folder, use the `examples` tag. + +``` +go test --tags=examples ./... +``` + +These tests require locally-running database instances. Run these databases +using [Docker Compose](https://docs.docker.com/compose/). ``` -go test --tags=exp ./... +docker-compose up -d ``` -To run the tests in the examples folder, a running PostgreSQL instance is -required. The tests use the following environment variables to connect to the +The tests use the following environment variables to connect to the database #### For PostgreSQL @@ -506,10 +515,6 @@ MYSQL_ROOT_PASSWORD mysecretpassword MYSQL_DATABASE dinotest ``` -``` -go test --tags=examples,exp ./... -``` - ### Regenerate expected test output If you need to update a large number of expected test output in the diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..b4990c0225 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +version: "3.8" +services: + mysql: + image: "mysql:8" + ports: + - "3306:3306" + restart: always + environment: + MYSQL_DATABASE: dinotest + MYSQL_PASSWORD: mysecretpassword + MYSQL_ROOT_PASSWORD: mysecretpassword + MYSQL_USER: root + + postgresql: + image: "postgres:13" + ports: + - "5432:5432" + restart: always + environment: + POSTGRES_DB: dinotest + POSTGRES_PASSWORD: mysecretpassword + POSTGRES_USER: postgres