Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/install/installer/pkg/components/openvsx-proxy/service_test.go
2501 views
1
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2
/// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package openvsx_proxy
6
7
import (
8
"testing"
9
10
"github.com/stretchr/testify/require"
11
corev1 "k8s.io/api/core/v1"
12
13
"github.com/gitpod-io/gitpod/installer/pkg/common"
14
config "github.com/gitpod-io/gitpod/installer/pkg/config/v1"
15
"github.com/gitpod-io/gitpod/installer/pkg/config/versions"
16
)
17
18
func TestServiceAnnotations(t *testing.T) {
19
annotations := map[string]string{"hello": "world"}
20
21
ctx := renderContextWithVSXProxyConfig(t, &config.OpenVSX{
22
Proxy: &config.OpenVSXProxy{
23
Proxy: config.Proxy{
24
ServiceAnnotations: annotations,
25
},
26
},
27
})
28
29
objects, err := service(ctx)
30
require.NoError(t, err)
31
32
require.Len(t, objects, 1, "must render only one object")
33
34
svc := objects[0].(*corev1.Service)
35
for k, v := range annotations {
36
require.Equalf(t, annotations[k], svc.Annotations[k],
37
"expected to find annotation %q:%q on openvsx-proxy service, but found %q:%q", k, v, k, svc.Annotations[k])
38
}
39
}
40
41
func renderContextWithVSXProxyConfig(t *testing.T, openvsxConfig *config.OpenVSX) *common.RenderContext {
42
ctx, err := common.NewRenderContext(config.Config{
43
OpenVSX: *openvsxConfig,
44
}, versions.Manifest{
45
Components: versions.Components{
46
PublicAPIServer: versions.Versioned{
47
Version: "commit-test-latest",
48
},
49
},
50
}, "test-namespace")
51
require.NoError(t, err)
52
53
return ctx
54
}
55
56