Commit a135552b authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

add option to run tests against configured database

parent a07475d4
Loading
Loading
Loading
Loading
+2 −1
Changes for AGENTS.md: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -24,12 +24,13 @@ Prefer the project commands already defined in the `Makefile`.
- Run development services: `make run`
- Format: `make format`
- Full test suite: `make test`
- Full test suite using the currently configured database connection: `make test TEST_DATABASE=configured`
- Focused Django tests: `JAMA_VAR_DIR=.jama_data uv run jama test rpc`
- Lint one file: `uv run ruff check src/rpc/methods.py`
- Format one file: `uv run ruff format src/rpc/methods.py`
- Build package: `make build`

`make test` runs from `src/` with `JAMA_VAR_DIR=.jama_test_data` and an in-memory SQLite database, then removes `.jama_test_data`. When running tests manually with another `JAMA_VAR_DIR`, remove that generated directory after the test run as well.
`make test` runs from `src/` with `JAMA_VAR_DIR=.jama_test_data` and an in-memory SQLite database, then removes `.jama_test_data`. Set `TEST_DATABASE=configured` to use the database connection loaded from the current `JAMA_VAR_DIR` instead. Django still creates and destroys its usual separate test database. When running tests manually with another generated `JAMA_VAR_DIR`, remove that directory after the test run as well.

## Environment Notes

+11 −2
Changes for Makefile: 11 added lines, 2 removed lines.
Original line number Diff line number Diff line
.PHONY: install install-hooks update run format test build publish help

TEST_DATABASE ?= memory

.cache/tandem:
	@mkdir -p $$(dirname $@)
	@curl -fsSL https://raw.githubusercontent.com/rosszurowski/tandem/main/install.sh | bash -
@@ -40,8 +42,15 @@ format: ## Formatage des sources avec Ruff
	uv run ruff check --fix
	uv run ruff format ./

test: ## Lancer les tests
	cd src && JAMA_VAR_DIR=.jama_test_data JAMA_SQLITE_DB_PATH=:memory: JAMA_USE_MODSHIB=0 uv run jama test --settings=jama.test_settings && rm -rf .jama_test_data
test: ## Lancer les tests (TEST_DATABASE=memory|configured)
	@if test "$(TEST_DATABASE)" = "memory"; then \
		cd src && JAMA_VAR_DIR=.jama_test_data JAMA_SQLITE_DB_PATH=:memory: JAMA_USE_MODSHIB=0 uv run jama test --settings=jama.test_settings && rm -rf .jama_test_data; \
	elif test "$(TEST_DATABASE)" = "configured"; then \
		cd src && JAMA_USE_MODSHIB=0 uv run jama test --settings=jama.test_settings; \
	else \
		echo 'TEST_DATABASE must be either "memory" or "configured"' >&2; \
		exit 2; \
	fi

build:build-ui-front  ## build package
	rm -rf dist