Skip to content

Commit ace427c

Browse files
TimSoethoutTim Soethout
authored andcommitted
commit regression test
1 parent 2bcf1dd commit ace427c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

completion_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,36 @@ func TestCompletionShell(t *testing.T) {
6363
}
6464
}
6565

66+
func TestCompletionFishFormat(t *testing.T) {
67+
// Regression test for https://github.com/urfave/cli/issues/2285
68+
// Fish completion was broken due to incorrect format specifiers
69+
70+
cmd := &Command{
71+
Name: "myapp",
72+
EnableShellCompletion: true,
73+
}
74+
75+
r := require.New(t)
76+
77+
// Test the fish shell completion renderer directly
78+
fishRender := shellCompletions["fish"]
79+
r.NotNil(fishRender, "fish completion renderer should exist")
80+
81+
output, err := fishRender(cmd, "myapp")
82+
r.NoError(err)
83+
84+
// Verify the function name is correctly formatted
85+
r.Contains(output, "function __myapp_perform_completion", "function name should contain app name")
86+
87+
// Verify no format errors (like %! or (string=) which indicate broken fmt.Sprintf)
88+
r.NotContains(output, "%!", "output should not contain format errors")
89+
r.NotContains(output, "(string=", "output should not contain invalid fish syntax")
90+
91+
// Verify the complete commands reference the app correctly
92+
r.Contains(output, "complete -c myapp", "complete command should reference app name")
93+
r.Contains(output, "(__myapp_perform_completion)", "completion function should be registered")
94+
}
95+
6696
func TestCompletionSubcommand(t *testing.T) {
6797
tests := []struct {
6898
name string

0 commit comments

Comments
 (0)