Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve assertions and remove import being imported more than once #51

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading