Solution to the test receipt-processor-challenge
-
docker >= 18
-
docker-compose >= 1.25
-
create the .env file with the environment variables in the root directory, take .template.env as an example
-
start project dependencies, this will raise a couple of docker images, one for postgresql and another for flyway,
./cicd/docker-compose.deps.yml
file is used:make start_dependencies
-
compile the project:
make compile
-
run test
- start project dependencies:
make start_dependencies
- run all tests:
make test
- run only one class of tests:
example:
make test-only TEST_CLASS="CLASS-NAME"
make test-only TEST_CLASS="com.dgg.receiptprocessorchallenge.ValidationsSpec"
- finally stop dependencies:
make stop_dependencies
- start project dependencies:
-
run sbt console inside docker, sbt is the tool used to build a scala application,
./cicd/docker-compose.dev.yml
file is used- run sbt:
make sbt
- from the console you can also compile and run tests
sbt:receipt-processor-challenge> compile
sbt:receipt-processor-challenge> test
sbt:receipt-processor-challenge> testOnly com.dgg.receiptprocessorchallenge.persistance.postgres.QueriesSpec
- exit with
ctrl + c
- finally stop dependencies:
make stop_dependencies
- run sbt:
-
run project:
- start run start dependencies and build the project using the file
./cicd/docker-compose.run.yml
:make start_run
- logs can be viewed using, exit with
ctrl + c
:docker logs -f main-sbt-1
- requests can be made to `http://localhost:8080/receipts/process
- finally stop run:
make stop_all
- start run start dependencies and build the project using the file
Important.- stop and start the dependencies if a branch change is made for development, enable git hook to check format when committing
git config core.hooksPath .git-hooks
ff the format is wrong you can use:
make format
format can be checked at any time with:
make checkFormat