Skip to content

Commit 7898b3f

Browse files
committed
kubeadm: update image pull tests
1 parent f6f3738 commit 7898b3f

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

cmd/kubeadm/app/preflight/checks_test.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -753,18 +753,20 @@ func TestSetHasItemOrAll(t *testing.T) {
753753
func TestImagePullCheck(t *testing.T) {
754754
fcmd := fakeexec.FakeCmd{
755755
RunScript: []fakeexec.FakeRunAction{
756-
// Test case 1: img1 and img2 exist, img3 doesn't exist
756+
// Test case 1: pull 3 images successfully
757+
func() ([]byte, []byte, error) { return nil, nil, nil },
757758
func() ([]byte, []byte, error) { return nil, nil, nil },
758759
func() ([]byte, []byte, error) { return nil, nil, nil },
759-
func() ([]byte, []byte, error) { return nil, nil, &fakeexec.FakeExitError{Status: 1} },
760760

761-
// Test case 2: images don't exist
762-
func() ([]byte, []byte, error) { return nil, nil, &fakeexec.FakeExitError{Status: 1} },
761+
// Test case 2: image pull errors
762+
func() ([]byte, []byte, error) { return nil, nil, nil },
763763
func() ([]byte, []byte, error) { return nil, nil, &fakeexec.FakeExitError{Status: 1} },
764764
func() ([]byte, []byte, error) { return nil, nil, &fakeexec.FakeExitError{Status: 1} },
765765
},
766766
CombinedOutputScript: []fakeexec.FakeCombinedOutputAction{
767-
// Test case1: pull only img3
767+
// Test case1: pull 3 images
768+
func() ([]byte, error) { return nil, nil },
769+
func() ([]byte, error) { return nil, nil },
768770
func() ([]byte, error) { return nil, nil },
769771
// Test case 2: fail to pull image2 and image3
770772
func() ([]byte, error) { return nil, nil },
@@ -781,10 +783,6 @@ func TestImagePullCheck(t *testing.T) {
781783
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
782784
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
783785
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
784-
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
785-
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
786-
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
787-
func(cmd string, args ...string) exec.Cmd { return fakeexec.InitFakeCmd(&fcmd, cmd, args...) },
788786
},
789787
LookPathFunc: func(cmd string) (string, error) { return "/usr/bin/docker", nil },
790788
}
@@ -803,7 +801,7 @@ func TestImagePullCheck(t *testing.T) {
803801
t.Fatalf("did not expect any warnings but got %q", warnings)
804802
}
805803
if len(errors) != 0 {
806-
t.Fatalf("expected 1 errors but got %d: %q", len(errors), errors)
804+
t.Fatalf("expected 0 errors but got %d: %q", len(errors), errors)
807805
}
808806

809807
warnings, errors = check.Check()

0 commit comments

Comments
 (0)