(t *testing.T)
| 201 | } |
| 202 | |
| 203 | func TestCreateContainerValidateFlags(t *testing.T) { |
| 204 | for _, tc := range []struct { |
| 205 | name string |
| 206 | args []string |
| 207 | expectedErr string |
| 208 | }{ |
| 209 | { |
| 210 | name: "with invalid --attach value", |
| 211 | args: []string{"--attach", "STDINFO", "myimage"}, |
| 212 | expectedErr: `invalid argument "STDINFO" for "-a, --attach" flag: valid streams are STDIN, STDOUT and STDERR`, |
| 213 | }, |
| 214 | } { |
| 215 | t.Run(tc.name, func(t *testing.T) { |
| 216 | cmd := newCreateCommand(test.NewFakeCli(&fakeClient{})) |
| 217 | cmd.SetOut(io.Discard) |
| 218 | cmd.SetErr(io.Discard) |
| 219 | cmd.SetArgs(tc.args) |
| 220 | |
| 221 | err := cmd.Execute() |
| 222 | if tc.expectedErr != "" { |
| 223 | assert.Check(t, is.ErrorContains(err, tc.expectedErr)) |
| 224 | } else { |
| 225 | assert.Check(t, is.Nil(err)) |
| 226 | } |
| 227 | }) |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | func TestNewCreateCommandWithWarnings(t *testing.T) { |
| 232 | testCases := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…