mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 19:01:54 +00:00
Replace 8 bash env modules with a single Python generator
(cli.meta.env) that materialises env/static.env + runtime context
into a gitignored .env. Each variable lives in its own handler
under utils/env/handlers/; defaults carry inline one-line `# ...`
comments.
Rename to the INFINITO_* schema:
- workflow inputs: APPS, SERVICES_DISABLED, CMD, DEBUG, WHITELIST,
BUNDLES, FULL_CYCLE, VARIANT, RUN_FLAGS, LIMIT_HOST, PARALLEL
- inventory: INVENTORY_DIR / INVENTORY_FILE / HOST_VARS_FILE,
PW_FILE -> INVENTORY_PASSWORD_FILE
- venv: VENV_BASE / VENV_FALLBACK / VENV_NAME
- new SPOT defaults: COMPILE_SILENCE, CONTAINER_NO_CA,
WAIT_HEALTH_TIMEOUT_S, PACKAGE_CACHE_FRONTEND_INIT_IMAGE,
promoted IMAGE_TAG from GHA-only to general passthrough
compose.yml hardening:
- inline \${VAR:-default} removed; strict \${VAR:?...} everywhere
- new integration lint blocks regressions
Tooling:
- scripts/install/all.sh owns the stamp-file install logic
(Makefile target delegates)
- scripts/meta/env/load.sh is the single shell entry point;
8 bash modules deleted
- new shell lint: no INFINITO_* defaults outside env/static.env
Tests:
- 93 new unit tests for utils/env/{builder,parser,runtime,writer}
- restructure tests/lint into repository/ (file-content rules) vs
filesystem/{shell,python,env}/ (filesystem-shape rules)
- drift + smoke integration tests against the generator
Docs:
- variables.md is now a pointer; per-variable docs live next to
the key in env/static.env / env/ci.env
- compose.yml.md drops the Default column
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
41 lines
1.7 KiB
Markdown
41 lines
1.7 KiB
Markdown
# Unit Tests 🧪
|
|
|
|
This page covers unit testing requirements, framework, and structure.
|
|
Run unit tests with `make test-unit`.
|
|
|
|
## Framework 🧰
|
|
|
|
- You MUST use Python `unittest` as the test framework.
|
|
- Tests MUST live under `tests/unit/`.
|
|
- Mirror the source tree: a file at `plugins/lookup/service.py` gets its tests at `tests/unit/plugins/lookup/test_service.py`.
|
|
|
|
## Requirements 📋
|
|
|
|
- You MUST add or update unit tests for every `*.py` file you touch.
|
|
- Each test MUST cover one isolated behavior. Do not test multiple concerns in a single test method.
|
|
- You MUST NOT write tests that only assert a file contains a string.
|
|
- You MUST NOT write tests for non-executable files such as `.yml` or `.j2`. Test the code that consumes them instead.
|
|
- You SHOULD name test methods after the behavior they verify, not the function name alone (e.g. `test_needed_false_when_disabled`).
|
|
- You SHOULD cover edge cases: empty inputs, missing keys, and boundary values, not only the happy path.
|
|
- You MAY use `unittest.mock` to isolate the unit under test from Ansible internals or external state.
|
|
|
|
## How to Create 🛠️
|
|
|
|
1. Identify the module under test (e.g. `plugins/lookup/service.py`).
|
|
2. Create the matching test file under `tests/unit/` if it does not exist.
|
|
3. Subclass `unittest.TestCase`.
|
|
4. Write one method per behavior. Build hypotheses before writing assertions.
|
|
5. Run `make test-unit` and verify all tests pass.
|
|
|
|
## Running Specific Tests 🏃
|
|
|
|
Use `INFINITO_TEST_PATTERN` to scope the test run to a single file or a glob:
|
|
|
|
```bash
|
|
# Run a single test file
|
|
make test-unit INFINITO_TEST_PATTERN=test_my_module.py
|
|
|
|
# Run all files matching a prefix
|
|
make test-unit INFINITO_TEST_PATTERN=test_applications*.py
|
|
```
|