Skip to content

Commit

Permalink
improve assertions and remove imports being imported more than once (#51
Browse files Browse the repository at this point in the history
)

Co-authored-by: Matous Jobanek <[email protected]>
  • Loading branch information
rsoaresd and MatousJobanek authored Jul 24, 2024
1 parent 9e17695 commit 3f9f1bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cmd/user-identity-mapper/user_identity_mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestUserIdentityMapper(t *testing.T) {
err := useridentitymapper.CreateUserIdentityMappings(context.TODO(), logger, cl)

// then
assert.EqualError(t, err, "unable to list users: mock error")
require.EqualError(t, err, "unable to list users: mock error")
})

t.Run("cannot list identities", func(t *testing.T) {
Expand All @@ -164,7 +164,7 @@ func TestUserIdentityMapper(t *testing.T) {
err := useridentitymapper.CreateUserIdentityMappings(context.TODO(), logger, cl)

// then
assert.EqualError(t, err, "unable to list identities: mock error")
require.EqualError(t, err, "unable to list identities: mock error")
})

t.Run("cannot create user-identity mapping", func(t *testing.T) {
Expand All @@ -183,7 +183,7 @@ func TestUserIdentityMapper(t *testing.T) {
err := useridentitymapper.CreateUserIdentityMappings(context.TODO(), logger, cl)

// then
assert.EqualError(t, err, `unable to create identity mapping for username "user1" and identity "identity1": mock error`)
require.EqualError(t, err, `unable to create identity mapping for username "user1" and identity "identity1": mock error`)
})
})
}
5 changes: 2 additions & 3 deletions pkg/cmd/generate/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/kubesaw/ksctl/pkg/configuration"
userv1 "github.com/openshift/api/user/v1"
v1 "github.com/openshift/api/user/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
Expand All @@ -23,7 +22,7 @@ func TestEnsureObject(t *testing.T) {
t.Run("for cluster type "+clusterType.String(), func(t *testing.T) {

t.Run("for User object", func(t *testing.T) {
verifyEnsureManifest(t, clusterType, &v1.User{})
verifyEnsureManifest(t, clusterType, &userv1.User{})
})

t.Run("for ServiceAccount object", func(t *testing.T) {
Expand Down Expand Up @@ -250,7 +249,7 @@ func TestWriteManifests(t *testing.T) {
for _, clusterType := range configuration.ClusterTypes {
for _, namespace := range []string{"johnspace", "second-namespace", ""} {
clusterCtx := newFakeClusterContext(ctx, clusterType.TheOtherType())
user, _ := prepareObjects(t, "john", namespace, &v1.User{})
user, _ := prepareObjects(t, "john", namespace, &userv1.User{})
require.NoError(t, cache.storeObject(clusterCtx, user))
sa, _ := prepareObjects(t, "john", namespace, &corev1.ServiceAccount{})
require.NoError(t, cache.storeObject(clusterCtx, sa))
Expand Down

0 comments on commit 3f9f1bf

Please sign in to comment.