Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sbryzak committed May 1, 2024
1 parent cdd1bcd commit cde7536
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions controllers/deactivation/deactivation_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,28 @@ func TestReconcile(t *testing.T) {
userSignupRedhat.Status.ScheduledDeactivationTimestamp = &now

r, req, cl := prepareReconcile(t, mur.Name, userTier30, mur, userSignupRedhat, config)

// First cause the status update to fail
cl.MockStatusUpdate = func(ctx context.Context, obj runtimeclient.Object, opts ...runtimeclient.UpdateOption) error {
switch obj.(type) {
case *toolchainv1alpha1.UserSignup:
return errors.New("mock error")
default:
return cl.Client.Status().Update(ctx, obj)
}
}

// when
res, err := r.Reconcile(context.TODO(), req)

Check failure on line 215 in controllers/deactivation/deactivation_controller_test.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint

ineffectual assignment to res (ineffassign)
require.Error(t, err)
require.Equal(t, "mock error", err.Error())

// Remove the mock update
cl.MockStatusUpdate = nil

// Attempt the reconcile again
res, err = r.Reconcile(context.TODO(), req)

// then
require.NoError(t, err)
require.False(t, res.Requeue, "requeue should not be set")
Expand Down

0 comments on commit cde7536

Please sign in to comment.