c1a29a331b6ce5b156cc4dd2f2ff9d2f5071b751
1 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
0e407f7f19 |
test: add TDD bug-capture test for #1022 — InvariantService persistence (#1109)
CI / build (push) Successful in 27s
CI / lint (push) Successful in 3m20s
CI / quality (push) Successful in 3m54s
CI / typecheck (push) Successful in 4m6s
CI / benchmark-regression (push) Has been skipped
CI / integration_tests (push) Successful in 6m55s
CI / unit_tests (push) Successful in 7m6s
CI / security (push) Successful in 8m4s
CI / e2e_tests (push) Successful in 10m47s
CI / docker (push) Successful in 1m9s
CI / coverage (push) Successful in 14m37s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Failing after 24m9s
## Summary Add Behave BDD and Robot Framework integration tests that capture bug #1022 — `InvariantService` stores invariants in an in-memory dict only, losing them across CLI process invocations. ### Motivation Per the project's TDD Bug Fix Workflow (CONTRIBUTING.md), every bug must first have a test written that captures the buggy behavior before the fix is implemented. This PR fulfills the TDD counterpart issue #1032 for bug #1022. ### What was done **Behave tests** (`features/tdd_invariant_persistence.feature`): Four scenarios tagged `@tdd_expected_fail @tdd_bug @tdd_bug_1022 @mock_only` that simulate separate CLI invocations via fresh `InvariantService` instances and assert cross-instance data visibility: 1. Project invariant persistence across service instances 2. Global invariant persistence across service instances 3. CLI add/list across separate invocations 4. Cross-instance soft-delete by invariant ID Step definitions in `features/steps/tdd_invariant_persistence_steps.py`. **Robot integration tests** (`robot/tdd_invariant_persistence.robot`): Three integration test cases with a helper script (`robot/helper_tdd_invariant_persistence.py`) that exercises add-then-list and add-then-remove across fresh service instances. ### How it passes CI All tests carry `@tdd_expected_fail`, which inverts the test result via the environment hooks (Behave) and listener (Robot). The underlying assertions fail (proving the bug exists), but are reported as passed to CI. The `@tdd_expected_fail` tag will be removed when bug #1022 is fixed, at which point the tests will run normally and must pass. ### Review fixes applied - **M1**: Moved `InvariantScope` import from function body in `robot/helper_tdd_invariant_persistence.py` to module-level top imports. - **m1**: Added `@mock_only` tag to `features/tdd_invariant_persistence.feature` — these tests use purely in-memory services and never touch the database. - **m2**: Added `exit_code == 0` assertion to `step_invoke_list_cli` in `features/steps/tdd_invariant_persistence_steps.py`, matching the pattern used in `step_invoke_add_cli`. - **m3**: Changed all `context: Any` parameter types to `context: Context` (from `behave.runner`), following the project-wide convention used in 335+ step files. - **m4**: Narrowed `except Exception` to `except NotFoundError` in `robot/helper_tdd_invariant_persistence.py`, matching the specific error being tested. - **n3**: Branch rebased onto latest `master`. ### Quality Gates - **lint**: ✅ passed - **typecheck**: ✅ passed (Pyright, 0 errors) - **unit_tests**: ✅ 1 feature, 4 scenarios, 16 steps — all passed via `@tdd_expected_fail` - **coverage**: ≥ 97% (test-only changes, no source modifications) Closes #1032 Co-authored-by: Jeffrey Phillips Freeman <the@jeffreyfreeman.me> Reviewed-on: #1109 Reviewed-by: Jeffrey Phillips Freeman <jeffrey.freeman@cleverthis.com> Co-authored-by: Brent E. Edwards <brent.edwards@cleverthis.com> Co-committed-by: Brent E. Edwards <brent.edwards@cleverthis.com> |