# README
Billups interview question
Coding interview for Billups company.
Service configuration
For the correct service work, you need to use environment variables or the .env
file.
In order to use the file, download the godotenv
binary file. General command to run .env
file:
godotenv -f .env [command]
Environment Variables
Variable | Default | Description |
---|---|---|
LOG_LEVEL | debug | Log level for logger. Possible options: trace, debug, info, warning, error, fatal and panic. |
SERVER_PORT | 8080 | Port on which app will run. |
SERVER_READ_TIMEOUT | 15s | App read response time. |
SERVER_WRITE_TIMEOUT | 15s | App write response time. |
Installation
Manual
You can build the service with the following terminal command:
go build ./cmd/...
Before running the service set up the environment variables and run the app:
# running the app
./app
# with .env file
godotenv -f .env ./app
Docker installation
Installation could be done with docker
and docker-compose
tools. Set up the environment variables or use .env
file.
docker-compose up --build
Testing
Unit-tests are using mocks generated by mockery. Mocks generation commands are embedded in-source using go:generate comments, so before running tests, you need to launch code generation.
# Install mockery tool
go install github.com/vektra/mockery/v2@@v2.10.0
# Run code generation
go generate ./...
# Run unit tests
go test ./...
# with .env file
godotenv -f .env go test ./...
Documentation
Documentation for the REST API is generated with go-swagger tool.
# generating swagger spec
swagger generate spec -o swagger.yml
# serving interactive UI in the browser
swagger serve -F swagger ./swagger.yml
Swagger UI is a graphical representation of swagger specifications. You can access REST documentation with "[base_endpoint]/doc/".