repositorypackage
0.0.0-20200913235748-99eafec89e17
Repository: https://github.com/cassioroos/e-core.git
Documentation: pkg.go.dev
# README
E-Core test
Dependencies
Baloo - For end-to-end test
Env - To handle environment variables
Go-Hclog - Simple logger package, key/value based
Testify - For tests :D
Requirements to run the project inside the Docker
- docker go to the docs
- docker-compose go to the docs
Executing application
It`s necessary to be at the root of the project.
Using docker-compose
docker-compose -f docker/docker-compose.yml up --build
Or
If you have make installed
make run
Or just execute via Go
go run .
Executing the operations
-
Echo (given)
- Return the matrix as a string in matrix format.
curl -F '[email protected]' "localhost:8080/echo"
-
Invert
- Return the matrix as a string in matrix format where the columns and rows are inverted
curl -F '[email protected]' "localhost:8080/invert"
-
Flatten
- Return the matrix as a 1 line string, with values separated by commas.
curl -F '[email protected]' "localhost:8080/flatten"
-
Sum
- Return the sum of the integers in the matrix
curl -F '[email protected]' "localhost:8080/sum"
-
Multiply
- Return the product of the integers in the matrix
curl -F '[email protected]' "localhost:8080/multiply"
Executing the tests
I divided the tests between end-to-end and unit test.
Running unit test
runs race detector, stop on the first test that fails and generates the coverage file
go test -mod=vendor -v -race -failfast -cover -coverprofile=coverage.out ./services ./handlers || exit 1
or simple
make test
To see the coverage as HTML
go tool cover -html=coverage.out
or
make coverage-html
Running end-to-end
It`s configured to run inside of the container as the tests need the application to be up. Docker-compose will run the app and will run another container with the source code, via entry point a .sh file will be executed in order to execute the tests
docker-compose -f docker/e2e/docker-compose.yml down
docker-compose -f docker/e2e/docker-compose.yml build
docker-compose -f docker/e2e/docker-compose.yml up --abort-on-container-exit --remove-orphans
docker-compose -f docker/e2e/docker-compose.yml stop
docker-compose -f docker/e2e/docker-compose.yml rm -f
simplifying with make
make e2e-test