Skip to content

Refactor: Use mockgen and improve test validation#1670

Merged
aknysh merged 2 commits intomainfrom
osterman/audit-test-logic-duplication
Oct 19, 2025
Merged

Refactor: Use mockgen and improve test validation#1670
aknysh merged 2 commits intomainfrom
osterman/audit-test-logic-duplication

Conversation

@osterman
Copy link
Member

what

  • Replaced manual mock implementation of storer.Storer with a mock generated by mockgen in internal/exec/describe_affected_utils_test.go.
  • Enhanced the test in internal/exec/template_funcs_test.go to more thoroughly validate the FuncMap and the returned AtmosFuncs instance.
  • Updated CLAUDE.md with mandatory guidelines for mock generation and testing production code paths.

why

  • Maintainability: Manual mock implementations are brittle and hard to maintain. Using mockgen ensures mocks are generated and updated automatically, reducing maintenance overhead.
  • Test Quality: The previous describe_affected_utils_test.go contained 81 lines of hand-written mock code. This is replaced by a cleaner, generated mock. The template_funcs_test.go test was trivial and has been expanded to provide more meaningful assertions.
  • Best Practices: CLAUDE.md now explicitly mandates the use of mockgen and emphasizes testing production code paths, preventing future occurrences of manual mocks and logic duplication in tests.

references

closes #123

@osterman osterman requested a review from a team as a code owner October 19, 2025 18:02
@github-actions github-actions bot added the size/l Large size PR label Oct 19, 2025
@osterman osterman added the no-release Do not create a new release (wait for additional code changes) label Oct 19, 2025
@codecov
Copy link

codecov bot commented Oct 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.10%. Comparing base (970325e) to head (4e0aa4a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1670      +/-   ##
==========================================
- Coverage   66.12%   66.10%   -0.02%     
==========================================
  Files         343      343              
  Lines       38778    38778              
==========================================
- Hits        25643    25636       -7     
- Misses      11147    11154       +7     
  Partials     1988     1988              
Flag Coverage Δ
unittests 66.10% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aknysh aknysh merged commit 8973388 into main Oct 19, 2025
53 checks passed
@aknysh aknysh deleted the osterman/audit-test-logic-duplication branch October 19, 2025 19:02
goruha added a commit that referenced this pull request Oct 19, 2025
…gha-cache

* 'fix-gha-cache' of github.com:cloudposse/atmos:
  Isolate AWS env vars during authentication (#1654)
  Changes auto-committed by Conductor (#1670)
  Add global --chdir flag for changing working directory (#1644)
  Fix: Preserve exit codes from shell commands and workflows (#1660)
  fix: isolate golangci-lint custom build to prevent git corruption (#1666)
@github-actions
Copy link

These changes were released in v1.195.0-rc.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-release Do not create a new release (wait for additional code changes) size/l Large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opt in or opt out analytics for how atmos is used

2 participants