Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Pierangelo Di Pilato <[email protected]>
  • Loading branch information
pierDipi committed Jan 15, 2025
1 parent c0d8ef3 commit 989644d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/auth/serviceaccount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

"k8s.io/apimachinery/pkg/api/equality"
apierrors "k8s.io/apimachinery/pkg/api/errors"
clientgotesting "k8s.io/client-go/testing"
duckv1 "knative.dev/pkg/apis/duck/v1"
kubeclient "knative.dev/pkg/client/injection/kube/client/fake"
Expand All @@ -31,11 +32,12 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"knative.dev/pkg/ptr"
rectesting "knative.dev/pkg/reconciler/testing"

eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
"knative.dev/eventing/pkg/apis/feature"
rttestingv1 "knative.dev/eventing/pkg/reconciler/testing/v1"
"knative.dev/pkg/ptr"
rectesting "knative.dev/pkg/reconciler/testing"
)

func TestGetOIDCServiceAccountNameForResource(t *testing.T) {
Expand Down Expand Up @@ -245,8 +247,8 @@ func TestSetupOIDCServiceAccount(t *testing.T) {

// Checks whether the created serviceAccount still exists or not.
sa, err = kubeclient.Get(ctx).CoreV1().ServiceAccounts(objectMeta.Namespace).Get(context.TODO(), expected.Name, metav1.GetOptions{})
if sa != nil || err == nil {
t.Errorf("DeleteOIDCServiceAccountIfExists failed to delete the serviceAccount: %+v", sa)
if !apierrors.IsNotFound(err) {
t.Errorf("DeleteOIDCServiceAccountIfExists failed to delete the serviceAccount: %+v: %+v", sa, err)
}

if trigger.Status.Auth != nil {
Expand Down Expand Up @@ -289,6 +291,7 @@ func TestSetupOIDCServiceAccount(t *testing.T) {
if condition.Type == eventingv1.TriggerConditionOIDCIdentityCreated {
if condition.Reason == "authentication-oidc feature disabled" {
matched = true
break
}
}
}
Expand Down Expand Up @@ -321,7 +324,7 @@ func TestDeleteOIDCServiceAccountIfExists(t *testing.T) {
}

sa, err := kubeclient.Get(ctx).CoreV1().ServiceAccounts(objectMeta.Namespace).Get(context.TODO(), expected.Name, metav1.GetOptions{})
if sa != nil || err == nil {
t.Errorf("DeleteOIDCServiceAccountIfExists failed to delete the serviceAccount: %+v", sa)
if !apierrors.IsNotFound(err) {
t.Errorf("DeleteOIDCServiceAccountIfExists failed to delete the serviceAccount: %+v: %+v", sa, err)
}
}

0 comments on commit 989644d

Please sign in to comment.