MCPcopy Index your code
hub / github.com/docker/cli / TestCreateContainerValidateFlags

Function TestCreateContainerValidateFlags

cli/command/container/create_test.go:203–229  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

201}
202
203func 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
231func TestNewCreateCommandWithWarnings(t *testing.T) {
232 testCases := []struct {

Callers

nothing calls this directly

Calls 4

SetArgsMethod · 0.80
newCreateCommandFunction · 0.70
SetOutMethod · 0.45
SetErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…