Current State
- Test file:
pkg/workflow/unquote_uses_test.go (280 LOC, 4 test functions, 0 assert/require usages; all checks use if got != want { t.Errorf })
- Source file:
pkg/workflow/compiler_yaml_step_conversion.go (functions: injectZizmorUnverifiedCreatorAnnotations, ConvertStepToYAML, unquoteUsesWithComments, (*Compiler).renderStepFromMap, formatStepEnvValueForYAML)
Strengths
- Already table-driven with descriptive case names.
- Good edge cases for malformed/unclosed quotes and hash-without-space.
- Realistic multi-step YAML inputs.
Prioritized Improvements
1. Missing / high-value tests
injectZizmorUnverifiedCreatorAnnotations has only 3 cases. Add:
- every entry in
unverifiedCreatorActionPrefixes (iterate the slice so new prefixes are auto-covered),
- a verified action (
actions/checkout@...) gets no annotation,
- tab indentation and
- uses: (list-item form; currently TrimLeft + CutPrefix("uses: ") would NOT match - uses: safedep/..., so document or fix the expected behaviour),
- a quoted value (
uses: "safedep/pmg@sha") — does it match the prefix?,
- empty input and idempotency (running twice should not double-inject, or the test should pin that it does).
ConvertStepToYAML and formatStepEnvValueForYAML have no direct tests in this file (only indirect ones in compiler_generation_test.go / multiline_test.go). Add a small table for formatStepEnvValueForYAML (string, bool, int, multi-line, string needing quoting) and a ConvertStepToYAML case checking that uses with a # v6 comment ends up unquoted end-to-end.
unquoteUsesWithComments: add CRLF input, uses: 'single-quoted # v1', and uses: "..." with extra spaces. The "multiple quotes on same line" case pins a questionable behaviour; add a comment saying it is intentional.
2. Testify assertion upgrades
Before / after
// Before
if result != tt.expected {
t.Errorf("unquoteUsesWithComments() = %q, want %q", result, tt.expected)
}
// After
assert.Equal(t, tt.expected, unquoteUsesWithComments(tt.input), "unquoteUsesWithComments should produce expected YAML")
Add "github.com/stretchr/testify/assert" to imports; use require.NoError for ConvertStepToYAML errors. Replacing the multi-line Got/Want messages also yields better diffs.
3. Table-driven refactors
- The three
unquoteUsesWithComments tests (TestUnquoteUsesWithComments, ...EdgeCases, ...RealWorldExamples) share an identical struct and loop. Merge into one table (or keep three with a shared helper) and t.Parallel() per subtest.
- Build
unverifiedCreatorActionPrefixes cases from the slice rather than hard-coding.
4. Organization / readability
- File name
unquote_uses_test.go also tests injectZizmorUnverifiedCreatorAnnotations; rename to compiler_yaml_step_conversion_test.go to match the source file.
- Use named raw-string constants for the repeated SHA pins to shorten cases.
Acceptance Checklist
Generated by 🧪 Daily Testify Uber Super Expert · copilot · auto · 15.3 AIC · ⌖ 9.64 AIC · ⊞ 7.3K · ◷
Current State
pkg/workflow/unquote_uses_test.go(280 LOC, 4 test functions, 0assert/requireusages; all checks useif got != want { t.Errorf })pkg/workflow/compiler_yaml_step_conversion.go(functions:injectZizmorUnverifiedCreatorAnnotations,ConvertStepToYAML,unquoteUsesWithComments,(*Compiler).renderStepFromMap,formatStepEnvValueForYAML)Strengths
Prioritized Improvements
1. Missing / high-value tests
injectZizmorUnverifiedCreatorAnnotationshas only 3 cases. Add:unverifiedCreatorActionPrefixes(iterate the slice so new prefixes are auto-covered),actions/checkout@...) gets no annotation,- uses:(list-item form; currentlyTrimLeft+CutPrefix("uses: ")would NOT match- uses: safedep/..., so document or fix the expected behaviour),uses: "safedep/pmg@sha") — does it match the prefix?,ConvertStepToYAMLandformatStepEnvValueForYAMLhave no direct tests in this file (only indirect ones incompiler_generation_test.go/multiline_test.go). Add a small table forformatStepEnvValueForYAML(string, bool, int, multi-line, string needing quoting) and aConvertStepToYAMLcase checking thatuseswith a# v6comment ends up unquoted end-to-end.unquoteUsesWithComments: add CRLF input,uses: 'single-quoted # v1', anduses: "..."with extra spaces. The "multiple quotes on same line" case pins a questionable behaviour; add a comment saying it is intentional.2. Testify assertion upgrades
Before / after
Add
"github.com/stretchr/testify/assert"to imports; userequire.NoErrorforConvertStepToYAMLerrors. Replacing the multi-lineGot/Wantmessages also yields better diffs.3. Table-driven refactors
unquoteUsesWithCommentstests (TestUnquoteUsesWithComments,...EdgeCases,...RealWorldExamples) share an identical struct and loop. Merge into one table (or keep three with a shared helper) andt.Parallel()per subtest.unverifiedCreatorActionPrefixescases from the slice rather than hard-coding.4. Organization / readability
unquote_uses_test.goalso testsinjectZizmorUnverifiedCreatorAnnotations; rename tocompiler_yaml_step_conversion_test.goto match the source file.Acceptance Checklist
assert/requireused instead of manualt.ErrorfcomparisonsunverifiedCreatorActionPrefixesmake test-unitpasses