Skip to content

Commit

Permalink
correct wrong type test
Browse files Browse the repository at this point in the history
  • Loading branch information
glennpratt committed Oct 4, 2024
1 parent 769bc87 commit 60f7536
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/client/fake/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1976,22 +1976,23 @@ var _ = Describe("Fake client", func() {
sa := &corev1.ServiceAccount{ObjectMeta: metav1.ObjectMeta{Name: "foo"}}
cl := NewClientBuilder().Build()

tokenRequest := &authenticationv1.TokenRequest{}
err := cl.SubResource("token").Create(context.Background(), sa, tokenRequest)
err := cl.SubResource("token").Create(context.Background(), sa, &authenticationv1.TokenRequest{})
Expect(err).To(HaveOccurred())
Expect(apierrors.IsNotFound(err)).To(BeTrue())
})

It("should error when creating a token with the wrong subresource type", func() {
cl := NewClientBuilder().Build()
err := cl.SubResource("token").Create(context.Background(), &corev1.ServiceAccount{}, &corev1.Namespace{})
Expect(err).To(HaveOccurred())
Expect(apierrors.IsBadRequest(err)).To(BeTrue())
})

It("should error when creating a token with the wrong type", func() {
cl := NewClientBuilder().Build()
err := cl.SubResource("token").Create(context.Background(), &corev1.Secret{}, &corev1.Namespace{})
Expect(apierrors.IsBadRequest(err)).To(BeTrue())
err := cl.SubResource("token").Create(context.Background(), &corev1.Secret{}, &authenticationv1.TokenRequest{})
Expect(err).To(HaveOccurred())
Expect(apierrors.IsNotFound(err)).To(BeTrue())
})

It("should leave typemeta empty on typed get", func() {
Expand Down

0 comments on commit 60f7536

Please sign in to comment.