From 19eeb1015556efe6d2c72ed9e3c1dc3d32ea084b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 8 Oct 2024 19:41:05 +0200 Subject: [PATCH] cli/command/image: fix TestNewSaveCommandSuccess to actually test This test was added in [moby@b2551c6] as part of a larger PR that implemented unit tests in various packages. In this specific test, it looks like the `imageSaveFunc` that's defined in the test-table was forgotten to be wired up, causing all tests to effectively be skipped. This patch wires up the function so that it's used in the test. [moby@b2551c6]: https://github.com/moby/moby/commit/b2551c619d30f163c3ab8c9ee53cdb09bfbeaa55 Signed-off-by: Sebastiaan van Stijn --- cli/command/image/save_test.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cli/command/image/save_test.go b/cli/command/image/save_test.go index fcd96727b9..8a399bdfa6 100644 --- a/cli/command/image/save_test.go +++ b/cli/command/image/save_test.go @@ -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 @@ -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])) @@ -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)