(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestFishCompletion(t *testing.T) { |
| 13 | // Given |
| 14 | cmd := buildExtendedTestCommand() |
| 15 | cmd.Flags = append(cmd.Flags, |
| 16 | &StringFlag{ |
| 17 | Name: "logfile", |
| 18 | TakesFile: true, |
| 19 | }, |
| 20 | &StringSliceFlag{ |
| 21 | Name: "foofile", |
| 22 | TakesFile: true, |
| 23 | }) |
| 24 | cmd.setupCommandGraph() |
| 25 | |
| 26 | oldTemplate := FishCompletionTemplate |
| 27 | defer func() { FishCompletionTemplate = oldTemplate }() |
| 28 | FishCompletionTemplate = "{{something" |
| 29 | |
| 30 | // test error case |
| 31 | _, err1 := cmd.ToFishCompletion() |
| 32 | assert.Error(t, err1) |
| 33 | |
| 34 | // reset the template |
| 35 | FishCompletionTemplate = oldTemplate |
| 36 | // When |
| 37 | res, err := cmd.ToFishCompletion() |
| 38 | |
| 39 | // Then |
| 40 | require.NoError(t, err) |
| 41 | expectFileContent(t, "testdata/expected-fish-full.fish", res) |
| 42 | } |
| 43 | |
| 44 | func TestFishCompletionShellComplete(t *testing.T) { |
| 45 | cmd := buildExtendedTestCommand() |
nothing calls this directly
no test coverage detected