Path: blob/main/install/installer/pkg/components/ide-proxy/service_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 ide_proxy56import (7"testing"89"github.com/stretchr/testify/require"10corev1 "k8s.io/api/core/v1"1112"github.com/gitpod-io/gitpod/installer/pkg/common"13config "github.com/gitpod-io/gitpod/installer/pkg/config/v1"14"github.com/gitpod-io/gitpod/installer/pkg/config/versions"15)1617func TestServiceAnnotations(t *testing.T) {18annotations := map[string]string{"hello": "world"}1920ctx := renderContextWithIDEProxyConfig(t, &config.Proxy{ServiceAnnotations: annotations})2122objects, err := service(ctx)23require.NoError(t, err)2425require.Len(t, objects, 1, "must render only one object")2627svc := objects[0].(*corev1.Service)28for k, v := range annotations {29require.Equalf(t, annotations[k], svc.Annotations[k],30"expected to find annotation %q:%q on ide-proxy service, but found %q:%q", k, v, k, svc.Annotations[k])31}32}3334func renderContextWithIDEProxyConfig(t *testing.T, proxyConfig *config.Proxy) *common.RenderContext {35ctx, err := common.NewRenderContext(config.Config{36Components: &config.Components{37IDE: &config.IDEComponents{38Proxy: proxyConfig,39},40},41}, versions.Manifest{42Components: versions.Components{43PublicAPIServer: versions.Versioned{44Version: "commit-test-latest",45},46},47}, "test-namespace")48require.NoError(t, err)4950return ctx51}525354