Check if file completion should be performed according to parameter 'shouldBePerformed'
(t *testing.T, cmdName string, shouldBePerformed bool)
| 28 | |
| 29 | // Check if file completion should be performed according to parameter 'shouldBePerformed' |
| 30 | func checkFileCompletion(t *testing.T, cmdName string, shouldBePerformed bool) { |
| 31 | t.Helper() |
| 32 | storage := storageFixture() |
| 33 | storage.Create(&release.Release{ |
| 34 | Name: "myrelease", |
| 35 | Info: &release.Info{Status: common.StatusDeployed}, |
| 36 | Chart: &chart.Chart{ |
| 37 | Metadata: &chart.Metadata{ |
| 38 | Name: "Myrelease-Chart", |
| 39 | Version: "1.2.3", |
| 40 | }, |
| 41 | }, |
| 42 | Version: 1, |
| 43 | }) |
| 44 | |
| 45 | testcmd := fmt.Sprintf("__complete %s ''", cmdName) |
| 46 | _, out, err := executeActionCommandC(storage, testcmd) |
| 47 | if err != nil { |
| 48 | t.Errorf("unexpected error, %s", err) |
| 49 | } |
| 50 | if !strings.Contains(out, "ShellCompDirectiveNoFileComp") != shouldBePerformed { |
| 51 | if shouldBePerformed { |
| 52 | t.Errorf("Unexpected directive ShellCompDirectiveNoFileComp when completing '%s'", cmdName) |
| 53 | } else { |
| 54 | |
| 55 | t.Errorf("Did not receive directive ShellCompDirectiveNoFileComp when completing '%s'", cmdName) |
| 56 | } |
| 57 | t.Log(out) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func TestCompletionFileCompletion(t *testing.T) { |
| 62 | checkFileCompletion(t, "completion", false) |
no test coverage detected
searching dependent graphs…