Skip to content

Commit

Permalink
Merge pull request docker#5520 from thaJeztah/fix_TestNewSaveCommandS…
Browse files Browse the repository at this point in the history
…uccess

cli/command/image: fix TestNewSaveCommandSuccess to actually test
  • Loading branch information
thaJeztah authored Oct 8, 2024
2 parents 1856229 + 19eeb10 commit b64f265
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions cli/command/image/save_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ func TestNewSaveCommandSuccess(t *testing.T) {
testCases := []struct {
args []string
isTerminal bool
imageSaveFunc func(images []string) (io.ReadCloser, error)
imageSaveFunc func(images []string, options image.SaveOptions) (io.ReadCloser, error)
deferredFunc func()
}{
{
args: []string{"-o", "save_tmp_file", "arg1"},
isTerminal: true,
imageSaveFunc: func(images []string) (io.ReadCloser, error) {
imageSaveFunc: func(images []string, _ image.SaveOptions) (io.ReadCloser, error) {
assert.Assert(t, is.Len(images, 1))
assert.Check(t, is.Equal("arg1", images[0]))
return io.NopCloser(strings.NewReader("")), nil
Expand All @@ -88,7 +88,7 @@ func TestNewSaveCommandSuccess(t *testing.T) {
{
args: []string{"arg1", "arg2"},
isTerminal: false,
imageSaveFunc: func(images []string) (io.ReadCloser, error) {
imageSaveFunc: func(images []string, _ image.SaveOptions) (io.ReadCloser, error) {
assert.Assert(t, is.Len(images, 2))
assert.Check(t, is.Equal("arg1", images[0]))
assert.Check(t, is.Equal("arg2", images[1]))
Expand All @@ -100,9 +100,7 @@ func TestNewSaveCommandSuccess(t *testing.T) {
tc := tc
t.Run(strings.Join(tc.args, " "), func(t *testing.T) {
cmd := NewSaveCommand(test.NewFakeCli(&fakeClient{
imageSaveFunc: func(images []string, options image.SaveOptions) (io.ReadCloser, error) {
return io.NopCloser(strings.NewReader("")), nil
},
imageSaveFunc: tc.imageSaveFunc,
}))
cmd.SetOut(io.Discard)
cmd.SetErr(io.Discard)
Expand Down

0 comments on commit b64f265

Please sign in to comment.