Path: blob/main/install/installer/pkg/components/openvsx-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 openvsx_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 := renderContextWithVSXProxyConfig(t, &config.OpenVSX{21Proxy: &config.OpenVSXProxy{22Proxy: config.Proxy{23ServiceAnnotations: annotations,24},25},26})2728objects, err := service(ctx)29require.NoError(t, err)3031require.Len(t, objects, 1, "must render only one object")3233svc := objects[0].(*corev1.Service)34for k, v := range annotations {35require.Equalf(t, annotations[k], svc.Annotations[k],36"expected to find annotation %q:%q on openvsx-proxy service, but found %q:%q", k, v, k, svc.Annotations[k])37}38}3940func renderContextWithVSXProxyConfig(t *testing.T, openvsxConfig *config.OpenVSX) *common.RenderContext {41ctx, err := common.NewRenderContext(config.Config{42OpenVSX: *openvsxConfig,43}, versions.Manifest{44Components: versions.Components{45PublicAPIServer: versions.Versioned{46Version: "commit-test-latest",47},48},49}, "test-namespace")50require.NoError(t, err)5152return ctx53}545556