Current State
- Test file:
pkg/cli/validators_test.go (424 LOC, 4 test functions, ~60 table cases, 0 testify usage)
- Source pair:
pkg/cli/validators.go (48 LOC, 2 exported funcs: ValidateWorkflowName, ValidateWorkflowIntent)
Strengths
- Table-driven with descriptive case names;
t.Parallel() at top level.
- Good boundary coverage (19/20 chars, whitespace trimming, unicode, long input).
Prioritized Improvements
1. Missing / high-value tests
ValidateWorkflowIntent uses len(trimmed) (bytes), not runes. Add a case like "日本語日本語日" (7 runes, 21 bytes) to pin the intended behavior; either fix the source to utf.RuneCountInString or document the byte semantics in the test.
ValidateWorkflowName: add cases for trailing newline ("abc\n"; confirms $ doesn't match before a final newline), non-ASCII letters ("wörkflow"), and a name with .md suffix.
- Duplicate case sets:
*_EdgeCases tests overlap with the main tests (e.g. boundary/whitespace cases); merge or dedupe.
2. Testify assertion upgrades
Before / after
// before
if tt.expectError {
if err == nil { t.Errorf(...); return }
if !strings.Contains(err.Error(), tt.errorMsg) { t.Errorf(...) }
} else if err != nil { t.Errorf(...) }
// after
if tt.expectError {
require.Error(t, err, "ValidateWorkflowName(%q) should fail", tt.input)
assert.Contains(t, err.Error(), tt.errorMsg)
return
}
require.NoError(t, err, "ValidateWorkflowName(%q) should succeed", tt.input)
Use assert.EqualError when the full message is fixed. The strings import is then only needed for strings.Repeat.
3. Table-driven refactors
- Split each table into
valid / invalid slices ([]string and []struct{input, wantErr string}) so expectError bool + empty errorMsg disappear.
- The
_EdgeCases variants omit errorMsg; make error message checking consistent across all failing cases.
- Add
t.Parallel() inside t.Run closures (copy of tt is safe on current Go).
4. Organization / readability
- Hoist the two repeated error strings into constants/vars to avoid drift from source.
- Collapse 4 test functions into 2 (
TestValidateWorkflowName, TestValidateWorkflowIntent) with grouped sections.
Acceptance Checklist
Generated by 🧪 Daily Testify Uber Super Expert · copilot · auto · 13.3 AIC · ⌖ 8.27 AIC · ⊞ 7.3K · ◷
Current State
pkg/cli/validators_test.go(424 LOC, 4 test functions, ~60 table cases, 0 testify usage)pkg/cli/validators.go(48 LOC, 2 exported funcs:ValidateWorkflowName,ValidateWorkflowIntent)Strengths
t.Parallel()at top level.Prioritized Improvements
1. Missing / high-value tests
ValidateWorkflowIntentuseslen(trimmed)(bytes), not runes. Add a case like"日本語日本語日"(7 runes, 21 bytes) to pin the intended behavior; either fix the source toutf.RuneCountInStringor document the byte semantics in the test.ValidateWorkflowName: add cases for trailing newline ("abc\n"; confirms$doesn't match before a final newline), non-ASCII letters ("wörkflow"), and a name with.mdsuffix.*_EdgeCasestests overlap with the main tests (e.g. boundary/whitespace cases); merge or dedupe.2. Testify assertion upgrades
Before / after
Use
assert.EqualErrorwhen the full message is fixed. Thestringsimport is then only needed forstrings.Repeat.3. Table-driven refactors
valid/invalidslices ([]stringand[]struct{input, wantErr string}) soexpectError bool+ emptyerrorMsgdisappear._EdgeCasesvariants omiterrorMsg; make error message checking consistent across all failing cases.t.Parallel()insidet.Runclosures (copy ofttis safe on current Go).4. Organization / readability
TestValidateWorkflowName,TestValidateWorkflowIntent) with grouped sections.Acceptance Checklist
github.com/stretchr/testify/assertandrequiret.Errorferror checks withrequire.Error/require.NoError/assert.Containsmake test-unitpasses