(t *testing.T)
| 22 | ) |
| 23 | |
| 24 | func TestRunValidateFlags(t *testing.T) { |
| 25 | for _, tc := range []struct { |
| 26 | name string |
| 27 | args []string |
| 28 | expectedErr string |
| 29 | }{ |
| 30 | { |
| 31 | name: "with conflicting --attach, --detach", |
| 32 | args: []string{"--attach", "stdin", "--detach", "myimage"}, |
| 33 | expectedErr: "conflicting options: cannot specify both --attach and --detach", |
| 34 | }, |
| 35 | { |
| 36 | name: "with invalid --detach-keys", |
| 37 | args: []string{"--detach-keys", "shift-a", "myimage"}, |
| 38 | expectedErr: "invalid detach keys (shift-a):", |
| 39 | }, |
| 40 | } { |
| 41 | t.Run(tc.name, func(t *testing.T) { |
| 42 | cmd := newRunCommand(test.NewFakeCli(&fakeClient{})) |
| 43 | cmd.SetOut(io.Discard) |
| 44 | cmd.SetErr(io.Discard) |
| 45 | cmd.SetArgs(tc.args) |
| 46 | |
| 47 | err := cmd.Execute() |
| 48 | if tc.expectedErr != "" { |
| 49 | assert.Check(t, is.ErrorContains(err, tc.expectedErr)) |
| 50 | } else { |
| 51 | assert.Check(t, is.Nil(err)) |
| 52 | } |
| 53 | }) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | func TestRunLabel(t *testing.T) { |
| 58 | fakeCLI := test.NewFakeCli(&fakeClient{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…