Skip to content

🏃 fix expect statement in conversion tests to be idiomatic #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions pkg/webhook/conversion/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ var _ = Describe("Conversion Webhook", func() {
}

scheme = kscheme.Scheme
Expect(jobsapis.AddToScheme(scheme)).Should(Succeed())

Expect(webhook.InjectScheme(scheme)).Should(Succeed())
Expect(jobsapis.AddToScheme(scheme)).To(Succeed())
Expect(webhook.InjectScheme(scheme)).To(Succeed())

var err error
decoder, err = NewDecoder(scheme)
Expand All @@ -70,7 +69,7 @@ var _ = Describe("Conversion Webhook", func() {
Body: ioutil.NopCloser(bytes.NewReader(payload.Bytes())),
}
webhook.ServeHTTP(respRecorder, req)
Expect(json.NewDecoder(respRecorder.Result().Body).Decode(convReview)).Should(Succeed())
Expect(json.NewDecoder(respRecorder.Result().Body).Decode(convReview)).To(Succeed())
return convReview
}

Expand Down Expand Up @@ -146,7 +145,7 @@ var _ = Describe("Conversion Webhook", func() {

convReview := doRequest(convReq)
Expect(convReview.Response.Result.Status).To(Equal("Failure"))
Expect(convReview.Response.ConvertedObjects).Should(BeEmpty())
Expect(convReview.Response.ConvertedObjects).To(BeEmpty())
})

It("should return error when dest/src objects are of same type", func() {
Expand All @@ -167,7 +166,7 @@ var _ = Describe("Conversion Webhook", func() {

convReview := doRequest(convReq)
Expect(convReview.Response.Result.Status).To(Equal("Failure"))
Expect(convReview.Response.ConvertedObjects).Should(BeEmpty())
Expect(convReview.Response.ConvertedObjects).To(BeEmpty())
})

It("should return error when the API group does not have a hub defined", func() {
Expand Down Expand Up @@ -197,7 +196,7 @@ var _ = Describe("Conversion Webhook", func() {

convReview := doRequest(convReq)
Expect(convReview.Response.Result.Status).To(Equal("Failure"))
Expect(convReview.Response.ConvertedObjects).Should(BeEmpty())
Expect(convReview.Response.ConvertedObjects).To(BeEmpty())
})

})