Skip to content

Commit 106b089

Browse files
committed
Fix root command test to work with new command structure
- Update TestRootCmd_Subcommands to use cmd.Name() instead of cmd.Use - Remove assertion for help command as it may not appear during unit testing - All tests now pass with the new positional argument structure
1 parent 30c1c47 commit 106b089

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

cmd/root_test.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func TestRootCmd_Subcommands(t *testing.T) {
155155

156156
commandNames := make([]string, len(commands))
157157
for i, cmd := range commands {
158-
commandNames[i] = cmd.Use
158+
commandNames[i] = cmd.Name()
159159
}
160160

161161
// Should have deploy command
@@ -171,15 +171,8 @@ func TestRootCmd_Subcommands(t *testing.T) {
171171
}
172172
assert.True(t, hasDiff, "Should have diff command")
173173

174-
// Should have help command (automatically added by Cobra)
175-
hasHelp := false
176-
for _, name := range commandNames {
177-
if strings.Contains(name, "help") {
178-
hasHelp = true
179-
break
180-
}
181-
}
182-
assert.True(t, hasHelp, "Should have help command")
174+
// Note: help and completion commands are automatically added by Cobra
175+
// but may not appear in Commands() during unit testing
183176
}
184177

185178
func TestRootCmd_FlagTypes(t *testing.T) {

0 commit comments

Comments
 (0)