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

Function TestGenFishCompletionFile

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

Source from the content-addressed store, hash-verified

99}
100
101func TestGenFishCompletionFile(t *testing.T) {
102 tmpFile, err := os.CreateTemp("", "cobra-test")
103 if err != nil {
104 t.Fatal(err.Error())
105 }
106
107 defer os.Remove(tmpFile.Name())
108
109 rootCmd := &Command{Use: "root", Args: NoArgs, Run: emptyRun}
110 child := &Command{
111 Use: "child",
112 ValidArgsFunction: validArgsFunc,
113 Run: emptyRun,
114 }
115 rootCmd.AddCommand(child)
116
117 assertNoErr(t, rootCmd.GenFishCompletionFile(tmpFile.Name(), false))
118}
119
120func TestFailGenFishCompletionFile(t *testing.T) {
121 tmpDir, err := os.MkdirTemp("", "cobra-test")

Callers

nothing calls this directly

Calls 5

AddCommandMethod · 0.95
GenFishCompletionFileMethod · 0.95
ErrorMethod · 0.80
NameMethod · 0.80
assertNoErrFunction · 0.70

Tested by

no test coverage detected