MCPcopy
hub / github.com/spf13/cobra / TestFailGenFishCompletionFile

Function TestFailGenFishCompletionFile

fish_completions_test.go:120–143  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

118}
119
120func TestFailGenFishCompletionFile(t *testing.T) {
121 tmpDir, err := os.MkdirTemp("", "cobra-test")
122 if err != nil {
123 t.Fatal(err.Error())
124 }
125
126 defer os.RemoveAll(tmpDir)
127
128 f, _ := os.OpenFile(filepath.Join(tmpDir, "test"), os.O_CREATE, 0400)
129 defer f.Close()
130
131 rootCmd := &Command{Use: "root", Args: NoArgs, Run: emptyRun}
132 child := &Command{
133 Use: "child",
134 ValidArgsFunction: validArgsFunc,
135 Run: emptyRun,
136 }
137 rootCmd.AddCommand(child)
138
139 got := rootCmd.GenFishCompletionFile(f.Name(), false)
140 if !errors.Is(got, os.ErrPermission) {
141 t.Errorf("got: %s, want: %s", got.Error(), os.ErrPermission.Error())
142 }
143}

Callers

nothing calls this directly

Calls 4

AddCommandMethod · 0.95
GenFishCompletionFileMethod · 0.95
ErrorMethod · 0.80
NameMethod · 0.80

Tested by

no test coverage detected