Skip to content

Chore | Remove tests that repeat others at the same level - #391

Merged
diego-ojeda-binbash merged 1 commit into
masterfrom
feature/test-overlap-review
Nov 27, 2026
Merged

diego-ojeda-binbash merged 1 commit into
masterfrom
feature/test-overlap-review

Conversation

@diego-ojeda-binbash

Copy link
Copy Markdown
Contributor

Part of #346: the overlap review between test types.

How overlap was measured

  1. Which lines each test runs: pytest --cov-context=test. That gave 27 groups of tests that run exactly the same lines.
  2. What each test asserts: each group was read by hand. Running the same lines isn't a repeat when the inputs or the assertions differ, e.g. a valid token vs an expired one.
  3. Proof after removing:
    • per-file line and branch coverage against master: 0 lines or branches lost, 85% → 85%
    • make mutation on auth.py and tf.py: the same 85 survivors

Rule applied: each behavior is checked at the cheapest level that catches its bug. A test stays when it adds something the others don't.

Removed (pytest 495 → 470, bats lifecycle 10 → 6)

File Before → after Why
test_runner.py 46 → 31 A literal copy (..._none_args_... called run() with no arguments, like ..._no_args_...). Subsets: the missing-binary message, and the override already inside the merge test. Attribute checks that every run test implies. exec re-testing run's env var merging. One test now checks that exec passes env_vars and working_dir on
test_tfrunner.py 14 → 8 TFRunner.run only forwards to Runner.run: its env var and argument tests repeated test_runner.py
test_path.py −2 The two pytester tests of get_root_path, which test_root_path.py covers with real git. The pytester plugin (root conftest.py) goes with them, and so does mutmut's also_copy
test_tf.py −1 test_init_with_args is the -migrate-state case of test_init_arguments
test_project.py −1 The render-destination test: the golden files of project create fail on the same bug (that's how #388 found it)
leverage_tofu_lifecycle.bats 10 → 6 "Refuses --layers inside a layer", "Refuses a layer that does not exist" and "Validates the layout on init" fail in the CLI before running tofu, as test_layers_errors and test_init_stops_on_an_invalid_layout already check. "Stops at the first failing layer" repeats test_layers_stop_at_the_first_failing_layer, and the lifecycle test already checks the exit code of a real tofu run. They ran on 5 CI jobs

Overlaps reviewed and kept

  • Valid/invalid pairs that run the same lines (check_sso_token, credentials, backend_config): different inputs, different results.
  • Example tests next to properties (test__parsing, test_backend_config vs test_properties): the examples document the behavior; the properties look for counterexamples.
  • The same behavior at two levels, where the higher one adds something real:
    • the tfvars and backend-config injection, through CliRunner with a mocked TFRunner, and in bats with real tofu (DO NOT MERGE | Sabotage check for #347 #348 proved the bats catch injection breaks)
    • --layers order: bats runs each layer in its real directory
  • Contract tests vs the validate-layout unit tests: the contract tests run on the ref-arch, while the unit tests cover the error branches.
  • The bats "git not installed" test: it's the only check of that behavior. It happens when the package is imported, before any command runs.

Gap found and covered

TFRunner.exec doesn't raise by default (raises=False), unlike Runner.exec, and no test checked it. Added test_exec_does_not_raise_by_default.

What each suite is for

Suite Checks Doesn't check
Unit (pytest, mocks at the boundary) logic and error branches of each module real binaries
CLI (CliRunner) arguments, exit codes, messages, the order of --layers that tofu accepts what's passed to it
Properties (hypothesis) invariants over generated inputs specific cases (that's what the examples are for)
Contract (ref-arch) the CLI on the real layout of le-tf-infra-aws AWS
Golden (project create) the generated project, verbatim tofu validate (needs providers)
bats the installed leverage with real tofu/terraform, no AWS anything a CLI test already catches
Ref-arch E2E the real flow against AWS —
Mutation (make mutation, by hand) that the tests of auth.py/tf.py really check —

🤖 Generated with Claude Code

Overlap review across the test suites (#346). Each removed test only
re-checked what a kept one already checks; with them gone no line or branch
loses coverage (85% before and after) and mutation testing keeps the same
85 survivors on auth.py and tf.py.

- test_runner.py 46 -> 31: a literal copy (no args vs "None" args), subsets
  (missing-binary message, override inside the merge test), attribute checks
  every run test implies, and exec re-testing run's env merging. One test now
  checks exec passes env_vars and working_dir on.
- test_tfrunner.py 14 -> 8: TFRunner.run only forwards to Runner.run, so its
  env and argument tests repeated test_runner.py. Gap found and covered:
  TFRunner.exec doesn't raise by default, unlike Runner.exec.
- test_path.py: the two pytester get_root_path tests, which test_root_path.py
  covers with real git. The pytester plugin (root conftest.py) goes with them.
- test_tf.py: test_init_with_args, a case of test_init_arguments.
- test_project.py: the render-destination test; the golden files of
  `project create` fail on the same bug.
- bats: 4 tofu lifecycle tests that never reach tofu or repeat a CliRunner
  test (--layers inside a layer, a missing layer, the layout check on init,
  stop at the first failing layer). They ran on 5 CI jobs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added maintenance Chores: CI, tooling, refactors without user-facing changes patch labels Nov 27, 2026
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 28 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 06418374-c29b-4174-ac48-99def59441d3
Commits

Reviewing files that changed from the base of the PR and between 2cd7373 and 337ce5b.

Files selected for processing: 8

  • conftest.py
  • pyproject.toml
  • tests/bats/leverage_tofu_lifecycle.bats
  • tests/test_modules/test_project.py
  • tests/test_modules/test_runner.py
  • tests/test_modules/test_tf.py
  • tests/test_modules/test_tfrunner.py
  • tests/test_path.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 46054779519

Coverage increased (+0.04%) to 85.443%

Details

  • Coverage increased (+0.04%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 4496
Covered Lines: 3920
Line Coverage: 87.19%
Relevant Branches: 1288
Covered Branches: 1022
Branch Coverage: 79.35%
Branches in Coverage %: Yes
Coverage Strength: 0.87 hits per line

💛 - Coveralls

@diego-ojeda-binbash diego-ojeda-binbash self-assigned this Nov 27, 2026
@diego-ojeda-binbash
diego-ojeda-binbash merged commit 2f4b258 into master Nov 27, 2026
28 checks passed
@diego-ojeda-binbash
diego-ojeda-binbash deleted the feature/test-overlap-review branch November 27, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Chores: CI, tooling, refactors without user-facing changes patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants