Skip to content

Commit

Permalink
Switch to justfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Lun4m committed Nov 8, 2024
1 parent ec30e29 commit 3c0c5b2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 46 deletions.
38 changes: 0 additions & 38 deletions integration_tests/Makefile

This file was deleted.

15 changes: 7 additions & 8 deletions integration_tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,21 @@ End-to-end tests are implemented inside `integration_tests\tests\end_to_end.rs`.
> defined in the `mock_permit_tables` function, otherwise the ingestor will not be able to
> insert the data into the database.
If you have Docker installed, you can run the tests locally using the provided
`Makefile`:
If you have Docker installed, you can run the tests locally using the provided `justfile`:

```terminal
# Run all tests
make test_all
just test_all
# Run unit tests only
make unit_tests
just test_unit
# Run integration tests only
make end_to_end
just test_end_to_end
# Debug a specific test (does not clean up the DB if `my_test_name` is an integration test)
TEST=my_test_name make debug_test
# Debug a specific test (does not clean up the DB if `test_name` is an integration test)
just debug_test test_name
# If any error occurs while running integration tests, you might need to reset the DB container manually
make clean
just clean
```
36 changes: 36 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
test_unit:
cargo build --workspace --tests
cargo test --no-fail-fast --workspace --exclude lard_tests -- --nocapture

test_all: setup && clean
cargo test --workspace --no-fail-fast -- --nocapture --test-threads=1

test_end_to_end: setup && clean
cargo test --test end_to_end --no-fail-fast -- --nocapture --test-threads=1

test_migrations: debug_migrations && clean

# Debug commands don't perfom the clean up action after running.
# This allows to manually check the state of the database.
debug_kafka: setup
cargo test --test end_to_end test_kafka --features debug --no-fail-fast -- --nocapture --test-threads=1

debug_test TEST: setup
cargo test {{TEST}} --features debug --no-fail-fast -- --nocapture --test-threads=1

debug_migrations: setup
@ cd migrations && go test -v ./...

setup:
@ echo "Starting Postgres docker container..."
docker run --name lard_tests -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres
@ echo; sleep 5
cargo build --workspace --tests
@ echo; echo "Loading DB schema..."; echo
@target/debug/prepare_postgres

clean:
@ echo "Stopping Postgres container..."
docker stop lard_tests
@ echo "Removing Postgres container..."
docker rm lard_tests

0 comments on commit 3c0c5b2

Please sign in to comment.