https://dev.to/joseboretto/integration-tests-in-go-with-cucumber-testcontainers-and-httpmock-5hb9
- Start docker compose
cd local
docker-compose up
- Set environment variables
DATABASE_USER=user
DATABASE_PASSWORD=password
DATABASE_NAME=db
DATABASE_HOST=localhost
DATABASE_PORT=5432
CHECK_ISBN_CLIENT_HOST=https://my-json-server.typicode.com/joseboretto/golang-testcontainers-gherkin-setup
- Run the application
cd cmd/golang-testcontainers-gherkin-setup
go run main.go
curl --location --request POST 'http://localhost:8000/api/v1/createBook' \
--header 'Content-Type: application/json' \
--data '{
"title": "title",
"total_pages": 10,
"isbn": "0-061-96436-0"
}'
This is a mock server. Check https://my-json-server.typicode.com/ for more information.
curl --location --request GET 'https://my-json-server.typicode.com/joseboretto/golang-testcontainers-gherkin-setup/isbn/0-061-96436-1'
curl --location --request GET 'https://my-json-server.typicode.com/joseboretto/golang-testcontainers-gherkin-setup/sendEmail'