Path: blob/main/install/installer/pkg/components/ws-manager-bridge/objects_test.go
2501 views
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.1/// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package wsmanagerbridge56import (7"testing"89"github.com/stretchr/testify/require"1011"github.com/gitpod-io/gitpod/installer/pkg/common"12config "github.com/gitpod-io/gitpod/installer/pkg/config/v1"13"github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental"14"github.com/gitpod-io/gitpod/installer/pkg/config/versions"15)1617func TestWorkspaceManagerList_WhenSkipSelfIsSet(t *testing.T) {18testCases := []struct {19Kind config.InstallationKind20SkipSelf bool21ExpectWorkspaceClusters bool22}{23{Kind: config.InstallationMeta, SkipSelf: true, ExpectWorkspaceClusters: false},24{Kind: config.InstallationMeta, SkipSelf: false, ExpectWorkspaceClusters: false}, // cannot mount anything it if there is nothing to mount25{Kind: config.InstallationFull, SkipSelf: true, ExpectWorkspaceClusters: false},26{Kind: config.InstallationFull, SkipSelf: false, ExpectWorkspaceClusters: true},27}2829for _, testCase := range testCases {30ctx := renderContextWithConfig(t, testCase.Kind, testCase.SkipSelf)3132wsclusters := WSManagerList(ctx)33if testCase.ExpectWorkspaceClusters {34require.NotEmptyf(t, wsclusters, "expected to render workspace clusters when skipSelf=%v", testCase.SkipSelf)35} else {36require.Emptyf(t, wsclusters, "expected not to render workspace clusters when skipSelf=%v", testCase.SkipSelf)37}38}39}4041func renderContextWithConfig(t *testing.T, kind config.InstallationKind, skipSelf bool) *common.RenderContext {42ctx, err := common.NewRenderContext(config.Config{43Kind: kind,44Experimental: &experimental.Config{45WebApp: &experimental.WebAppConfig{46WorkspaceManagerBridge: &experimental.WsManagerBridgeConfig{47SkipSelf: skipSelf,48},49},50},51}, versions.Manifest{52Components: versions.Components{53PublicAPIServer: versions.Versioned{54Version: "commit-test-latest",55},56},57}, "test-namespace")58require.NoError(t, err)5960return ctx61}626364