Skip to content

Commit

Permalink
Rename api error functions
Browse files Browse the repository at this point in the history
  • Loading branch information
IrvingMg committed Apr 3, 2024
1 parent df12e67 commit 2e6756e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pkg/util/testing/error_matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ func (em errorMatcher) String() string {

type apiError func(error) bool

func (em errorMatcher) IsApiError(err error) bool {
func (em errorMatcher) isAPIError(err error) bool {
return []apiError{apierrors.IsNotFound, apierrors.IsForbidden, apierrors.IsInvalid}[em](err)
}

type isErrorMatch struct {
name errorMatcher
}

func BeError(name errorMatcher) types.GomegaMatcher {
func BeAPIError(name errorMatcher) types.GomegaMatcher {
return &isErrorMatch{
name: name,
}
Expand All @@ -110,7 +110,7 @@ func (matcher *isErrorMatch) Match(actual interface{}) (success bool, err error)
return false, fmt.Errorf("%s expects an error", matcher.name.String())
}

return err != nil && matcher.name.IsApiError(err), nil
return err != nil && matcher.name.isAPIError(err), nil
}

func (matcher *isErrorMatch) FailureMessage(actual interface{}) (message string) {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/webhook/localqueue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var _ = ginkgo.Describe("Queue validating webhook", func() {
ginkgo.It("Should reject bad value for spec.clusterQueue", func() {
ginkgo.By("Creating a new Queue")
obj := testing.MakeLocalQueue(queueName, ns.Name).ClusterQueue("invalid_name").Obj()
gomega.Expect(k8sClient.Create(ctx, obj)).Should(testing.BeError(testing.InvalidError))
gomega.Expect(k8sClient.Create(ctx, obj)).Should(testing.BeAPIError(testing.InvalidError))
})
ginkgo.It("Should reject the change of spec.clusterQueue", func() {
ginkgo.By("Creating a new Queue")
Expand All @@ -43,7 +43,7 @@ var _ = ginkgo.Describe("Queue validating webhook", func() {
gomega.Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(obj), &updatedQ)).Should(gomega.Succeed())
updatedQ.Spec.ClusterQueue = "bar"
return k8sClient.Update(ctx, &updatedQ)
}, util.Timeout, util.Interval).Should(testing.BeError(testing.InvalidError))
}, util.Timeout, util.Interval).Should(testing.BeAPIError(testing.InvalidError))
})
})
})

0 comments on commit 2e6756e

Please sign in to comment.