Skip to content

Commit

Permalink
wip test new spacelister api
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrancisc committed Sep 20, 2023
1 parent 6135f39 commit 8f6ac42
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/codeready-toolchain/toolchain-e2e

require (
github.com/codeready-toolchain/api v0.0.0-20230823083409-fe9ca973d9a9
github.com/codeready-toolchain/api v0.0.0-20230918195153-739e8fb09a33
github.com/codeready-toolchain/toolchain-common v0.0.0-20230823084119-693476668406
github.com/davecgh/go-spew v1.1.1
github.com/fatih/color v1.12.0
Expand Down Expand Up @@ -121,3 +121,5 @@ require (
)

go 1.19

replace github.com/codeready-toolchain/toolchain-common => /Users/fmuntean/go/src/github.com/codeready-toolchain/toolchain-common
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,8 @@ github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:z
github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo=
github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA=
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
github.com/codeready-toolchain/api v0.0.0-20230823083409-fe9ca973d9a9 h1:ytFqNSSEvgevqvwMilmmqlrrDH1O/qUwzg8bO3CxCiY=
github.com/codeready-toolchain/api v0.0.0-20230823083409-fe9ca973d9a9/go.mod h1:nn3W6eKb9PFIVwSwZW7wDeLACMBOwAV+4kddGuN+ARM=
github.com/codeready-toolchain/toolchain-common v0.0.0-20230823084119-693476668406 h1:AkBhFV2tJhQaejTjntIhFC7r1FeLlQEiAL2gcn5/oW0=
github.com/codeready-toolchain/toolchain-common v0.0.0-20230823084119-693476668406/go.mod h1:wvbndymhFMqyc8syiaanid91GsywkDfuVyiTjdyiqNM=
github.com/codeready-toolchain/api v0.0.0-20230918195153-739e8fb09a33 h1:hxXfcFq2JgFISVxrkISg8m9DZMzpcPWRjPspx3M3Sxo=
github.com/codeready-toolchain/api v0.0.0-20230918195153-739e8fb09a33/go.mod h1:nn3W6eKb9PFIVwSwZW7wDeLACMBOwAV+4kddGuN+ARM=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
Expand Down
20 changes: 12 additions & 8 deletions test/e2e/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ func TestSpaceLister(t *testing.T) {
identityID: uuid.Must(uuid.NewV4()),
},
}
appStudioTierRolesWSoption := commonproxy.WithAvailableRoles([]string{"admin", "contributor", "maintainer"})

// create the users before the subtests, so they exist for the duration of the whole test
for _, user := range users {
Expand Down Expand Up @@ -692,7 +693,7 @@ func TestSpaceLister(t *testing.T) {

// then
require.NoError(t, err)
verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["car"], true), *workspace)
verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["car"], true, appStudioTierRolesWSoption), *workspace)
})

t.Run("cannot get bus workspace", func(t *testing.T) {
Expand Down Expand Up @@ -723,7 +724,7 @@ func TestSpaceLister(t *testing.T) {

// then
require.NoError(t, err)
verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["bus"], true), *busWS)
verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["bus"], true, appStudioTierRolesWSoption), *busWS)
})

t.Run("can get car workspace", func(t *testing.T) {
Expand All @@ -732,7 +733,7 @@ func TestSpaceLister(t *testing.T) {

// then
require.NoError(t, err)
verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["car"], false), *carWS)
verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["car"], false, appStudioTierRolesWSoption), *carWS)
})
})

Expand All @@ -755,7 +756,7 @@ func TestSpaceLister(t *testing.T) {

// then
require.NoError(t, err)
verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["bus"], false), *busWS)
verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["bus"], false, appStudioTierRolesWSoption), *busWS)
})

t.Run("can get car workspace", func(t *testing.T) {
Expand All @@ -764,7 +765,7 @@ func TestSpaceLister(t *testing.T) {

// then
require.NoError(t, err)
verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["car"], false), *carWS)
verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["car"], false, appStudioTierRolesWSoption), *carWS)
})

t.Run("can get bicycle workspace", func(t *testing.T) {
Expand All @@ -773,7 +774,7 @@ func TestSpaceLister(t *testing.T) {

// then
require.NoError(t, err)
verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["bicycle"], true), *bicycleWS)
verifyHasExpectedWorkspace(t, expectedWorkspaceFor(t, awaitilities.Host(), users["bicycle"], true, appStudioTierRolesWSoption), *bicycleWS)
})
})

Expand Down Expand Up @@ -1055,11 +1056,11 @@ func verifyHasExpectedWorkspace(t *testing.T, expectedWorkspace toolchainv1alpha
t.Errorf("expected workspace %s not found", expectedWorkspace.Name)
}

func expectedWorkspaceFor(t *testing.T, hostAwait *wait.HostAwaitility, user *proxyUser, isHomeWorkspace bool) toolchainv1alpha1.Workspace {
func expectedWorkspaceFor(t *testing.T, hostAwait *wait.HostAwaitility, user *proxyUser, isHomeWorkspace bool, additionalWSOptions ...commonproxy.WorkspaceOption) toolchainv1alpha1.Workspace {
space, err := hostAwait.WaitForSpace(t, user.compliantUsername, wait.UntilSpaceHasAnyTargetClusterSet(), wait.UntilSpaceHasAnyTierNameSet())
require.NoError(t, err)

ws := commonproxy.NewWorkspace(user.compliantUsername,
commonWSoptions := []commonproxy.WorkspaceOption{
commonproxy.WithObjectMetaFrom(space.ObjectMeta),
commonproxy.WithNamespaces([]toolchainv1alpha1.SpaceNamespace{
{
Expand All @@ -1069,6 +1070,9 @@ func expectedWorkspaceFor(t *testing.T, hostAwait *wait.HostAwaitility, user *pr
}),
commonproxy.WithOwner(user.signup.Name),
commonproxy.WithRole("admin"),
}
ws := commonproxy.NewWorkspace(user.compliantUsername,
append(commonWSoptions, additionalWSOptions...)...,
)
// if the user is the same as the one who created the workspace, then expect type should be "home"
if isHomeWorkspace {
Expand Down

0 comments on commit 8f6ac42

Please sign in to comment.