Skip to content

Commit

Permalink
tests: fix nil point error for kubeClient
Browse files Browse the repository at this point in the history
testInit is later than usage of kubeClient, this
would lead to nil pointer error when do go_parallel_test

Signed-off-by: Howard Zhang <[email protected]>
  • Loading branch information
zhlhahaha committed Oct 19, 2022
1 parent 52a3f52 commit 6a8be64
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/virtctl/imageupload/imageupload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,14 +667,14 @@ var _ = Describe("ImageUpload", func() {
})

It("Upload fails when using a nonexistent storageClass", func() {
testInit(http.StatusInternalServerError)
invalidStorageClass := "no-sc"
kubeClient.Fake.PrependReactor("get", "storageclasses", func(action testing.Action) (bool, runtime.Object, error) {
_, ok := action.(testing.GetAction)
Expect(ok).To(BeTrue())
return false, nil, nil
})

testInit(http.StatusInternalServerError)
cmd := clientcmd.NewRepeatableVirtctlCommand(commandName, "dv", targetName, "--size", pvcSize,
"--uploadproxy-url", server.URL, "--insecure", "--image-path", imagePath, "--storage-class", invalidStorageClass)
Expect(cmd()).NotTo(Succeed())
Expand Down

0 comments on commit 6a8be64

Please sign in to comment.