(t *testing.T)
| 118 | } |
| 119 | |
| 120 | func 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 | } |
nothing calls this directly
no test coverage detected