mirror of https://github.com/docker/cli.git
Use t.Run() for tests
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
125302cfa6
commit
b900676523
|
@ -64,12 +64,14 @@ func TestNewRemoveCommandErrors(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cmd := NewRemoveCommand(test.NewFakeCli(&fakeClient{
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
imageRemoveFunc: tc.imageRemoveFunc,
|
cmd := NewRemoveCommand(test.NewFakeCli(&fakeClient{
|
||||||
}))
|
imageRemoveFunc: tc.imageRemoveFunc,
|
||||||
cmd.SetOutput(ioutil.Discard)
|
}))
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
cmd.SetArgs(tc.args)
|
||||||
|
testutil.ErrorContains(t, cmd.Execute(), tc.expectedError)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +80,7 @@ func TestNewRemoveCommandSuccess(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
imageRemoveFunc func(image string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
|
imageRemoveFunc func(image string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
|
||||||
expectedErrMsg string
|
expectedStderr string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Image Deleted",
|
name: "Image Deleted",
|
||||||
|
@ -96,7 +98,7 @@ func TestNewRemoveCommandSuccess(t *testing.T) {
|
||||||
assert.Equal(t, true, options.Force)
|
assert.Equal(t, true, options.Force)
|
||||||
return []types.ImageDeleteResponseItem{}, notFound{"image1"}
|
return []types.ImageDeleteResponseItem{}, notFound{"image1"}
|
||||||
},
|
},
|
||||||
expectedErrMsg: "Error: No such image: image1",
|
expectedStderr: "Error: No such image: image1",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -119,14 +121,14 @@ func TestNewRemoveCommandSuccess(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
cli := test.NewFakeCli(&fakeClient{imageRemoveFunc: tc.imageRemoveFunc})
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
cmd := NewRemoveCommand(cli)
|
cli := test.NewFakeCli(&fakeClient{imageRemoveFunc: tc.imageRemoveFunc})
|
||||||
cmd.SetOutput(ioutil.Discard)
|
cmd := NewRemoveCommand(cli)
|
||||||
cmd.SetArgs(tc.args)
|
cmd.SetOutput(ioutil.Discard)
|
||||||
assert.NoError(t, cmd.Execute())
|
cmd.SetArgs(tc.args)
|
||||||
if tc.expectedErrMsg != "" {
|
assert.NoError(t, cmd.Execute())
|
||||||
assert.Equal(t, tc.expectedErrMsg, cli.ErrBuffer().String())
|
assert.Equal(t, tc.expectedStderr, cli.ErrBuffer().String())
|
||||||
}
|
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("remove-command-success.%s.golden", tc.name))
|
||||||
golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("remove-command-success.%s.golden", tc.name))
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
|
|
Loading…
Reference in New Issue