Skip to content

Commit

Permalink
chore(RHTAPWATCH-1237): Reorganize workspace-manager test suites
Browse files Browse the repository at this point in the history
Since functional tests BeforeSuite runs all the tests, separate
package for unit and functional tests.

Jira-Url: https://issues.redhat.com/browse/RHTAPWATCH-1237
Signed-off-by: Homaja Marisetty <[email protected]>
  • Loading branch information
hmariset committed Sep 16, 2024
1 parent ee4dc19 commit d413652
Show file tree
Hide file tree
Showing 4 changed files with 396 additions and 374 deletions.
10 changes: 6 additions & 4 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
}

type NamespaceWithAccess func(e *echo.Echo, c echo.Context, authCl authorizationv1Client.AuthorizationV1Interface, allNamespaces []core.Namespace) ([]core.Namespace, error)

// Given all relevant user namespaces, return all workspaces for the calling user
func getWorkspacesWithAccess(
e *echo.Echo, c echo.Context, allNamespaces []core.Namespace,
e *echo.Echo, c echo.Context, allNamespaces []core.Namespace, getNamespacesWithAccess NamespaceWithAccess,
) (crt.WorkspaceList, error) {
cfg, err := config.GetConfig()
if err != nil {
Expand Down Expand Up @@ -103,7 +105,7 @@ func getWorkspacesWithAccess(

// Get all the namespace in which the calling user is allowed to perform enough actions
// to allow workspace access
func getNamespacesWithAccess(
var getNamespacesWithAccess = func(
e *echo.Echo,
c echo.Context,
authCl authorizationv1Client.AuthorizationV1Interface,
Expand Down Expand Up @@ -232,7 +234,7 @@ func main() {
if err != nil {
e.Logger.Fatal(err)
}
workspaces, err := getWorkspacesWithAccess(e, c, userNamespaces)
workspaces, err := getWorkspacesWithAccess(e, c, userNamespaces, getNamespacesWithAccess)
if err != nil {
e.Logger.Fatal(err)
}
Expand All @@ -248,7 +250,7 @@ func main() {
if err != nil {
e.Logger.Fatal(err)
}
workspaces, err := getWorkspacesWithAccess(e, c, userNamespaces)
workspaces, err := getWorkspacesWithAccess(e, c, userNamespaces, getNamespacesWithAccess)
if err != nil {
e.Logger.Fatal(err)
}
Expand Down
Loading

0 comments on commit d413652

Please sign in to comment.