-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for WsManagerList function
Ensure that no workspace clusters are returned when either skipSelf is set or the installation is not a full one.
- Loading branch information
Andrew Farries
committed
May 4, 2022
1 parent
6b0281a
commit 8016623
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
install/installer/pkg/components/ws-manager-bridge/objects_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) 2022 Gitpod GmbH. All rights reserved. | ||
// Licensed under the MIT License. See License-MIT.txt in the project root for license information. | ||
|
||
package wsmanagerbridge | ||
|
||
import ( | ||
"github.com/gitpod-io/gitpod/installer/pkg/common" | ||
"github.com/gitpod-io/gitpod/installer/pkg/config/v1" | ||
"github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental" | ||
"github.com/gitpod-io/gitpod/installer/pkg/config/versions" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestWorkspaceManagerList_WhenSkipSelfIsSet(t *testing.T) { | ||
testCases := []struct { | ||
SkipSelf bool | ||
InstallationKind config.InstallationKind | ||
ExpectWorkspaceClusters bool | ||
}{ | ||
{SkipSelf: true, InstallationKind: config.InstallationFull, ExpectWorkspaceClusters: false}, | ||
{SkipSelf: true, InstallationKind: config.InstallationMeta, ExpectWorkspaceClusters: false}, | ||
{SkipSelf: false, InstallationKind: config.InstallationFull, ExpectWorkspaceClusters: true}, | ||
{SkipSelf: false, InstallationKind: config.InstallationMeta, ExpectWorkspaceClusters: false}, | ||
} | ||
|
||
for _, testCase := range testCases { | ||
ctx := renderContextWithConfig(t, testCase.SkipSelf, testCase.InstallationKind) | ||
|
||
wsclusters := WSManagerList(ctx) | ||
if testCase.ExpectWorkspaceClusters { | ||
require.NotEmpty(t, wsclusters, "expected to render workspace clusters when skipSelf=%v, kind=%s", | ||
testCase.SkipSelf, testCase.InstallationKind) | ||
} | ||
} | ||
} | ||
|
||
func renderContextWithConfig(t *testing.T, skipSelf bool, installationKind config.InstallationKind) *common.RenderContext { | ||
ctx, err := common.NewRenderContext(config.Config{ | ||
Kind: installationKind, | ||
Experimental: &experimental.Config{ | ||
WebApp: &experimental.WebAppConfig{ | ||
WorkspaceManagerBridge: &experimental.WsManagerBridgeConfig{ | ||
SkipSelf: skipSelf, | ||
}, | ||
}, | ||
}, | ||
}, versions.Manifest{ | ||
Components: versions.Components{ | ||
PublicAPIServer: versions.Versioned{ | ||
Version: "commit-test-latest", | ||
}, | ||
}, | ||
}, "test-namespace") | ||
require.NoError(t, err) | ||
|
||
return ctx | ||
} |