Strengthen fix --dir test coverage and migrate fix_dir_flag_test to testify#53783
fix --dir test coverage and migrate fix_dir_flag_test to testify#53783Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
fix --dir test coverage and migrate fix_dir_flag_test to testify
There was a problem hiding this comment.
Pull request overview
Expands fix --dir test coverage and adopts Testify assertions.
Changes:
- Adds table-driven directory and edge-case tests.
- Adds unit tests for codemod and workflow-root helpers.
- Extracts shared test helpers.
Show a summary per file
| File | Description |
|---|---|
pkg/cli/fix_dir_flag_test.go |
Refactors and expands fix-command tests. |
Review details
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Suppressed comments (1)
pkg/cli/fix_dir_flag_test.go:214
- This second normalization case also uses
filepath.Join, which cleans the path beforeresolveWorkflowRootreceives it. As written, it does not exercise the fallback branch’s normalization behavior.
filePath: filepath.Join(".", "a", "..", "b", "foo.md"),
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Balanced
| }, | ||
| { | ||
| name: "messy path under github workflows is normalized", | ||
| filePath: filepath.Join(".", "a", "..", "b", ".github", "workflows", "nested", "foo.md"), |
There was a problem hiding this comment.
Fixed in 8038cf0: both messy-path cases now build inputs with a joinUnclean helper that keeps the . and .. segments intact, so removing filepath.Clean from resolveWorkflowRoot fails the test.
There was a problem hiding this comment.
Correction: the fix landed in commit 6ce853e, not 8038cf0.
|
@copilot run pr-finisher |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
PR Triage
Test-only change (assertion style migration + coverage). CI is mostly green (1 cancelled run, likely flaky/rerun-worthy). Safe to auto-merge once CI is fully green.
|
pkg/cli/fix_dir_flag_test.gocovered core--dirhappy paths but missed helper-level unit tests and edge cases, and still used legacy raw assertion patterns. This updates the file to match package testing conventions (assert/require) while expanding coverage for dir resolution and codemod helper behavior.Assertion/style upgrade in
fix_dir_flag_test.got.Fatalf/t.Errorchecks withrequire.*for setup/execution gates andassert.*for content checks.--dirresolution/discovery vs broader codemod behavior tests elsewhere).Reduced duplication with shared helpers + table-driven flow
writeFixWorkflow,chdirTemp,assertMigratedTimeoutField).TestFixWithDirFlag.Added missing
--diredge-case coverageWorkflowDirbehavior checks.Added dedicated unit tests for untested helpers in
fix_command.goTestResolveWorkflowRoot(including nested.github/workflows, fallback-to-dir behavior, and cleaned/messy paths).TestWasCodemodApplied.TestWasAnyCodemodApplied.