Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/install/installer/pkg/components/ide-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 ide_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 := renderContextWithIDEProxyConfig(t, &config.Proxy{ServiceAnnotations: annotations})
22
23
objects, err := service(ctx)
24
require.NoError(t, err)
25
26
require.Len(t, objects, 1, "must render only one object")
27
28
svc := objects[0].(*corev1.Service)
29
for k, v := range annotations {
30
require.Equalf(t, annotations[k], svc.Annotations[k],
31
"expected to find annotation %q:%q on ide-proxy service, but found %q:%q", k, v, k, svc.Annotations[k])
32
}
33
}
34
35
func renderContextWithIDEProxyConfig(t *testing.T, proxyConfig *config.Proxy) *common.RenderContext {
36
ctx, err := common.NewRenderContext(config.Config{
37
Components: &config.Components{
38
IDE: &config.IDEComponents{
39
Proxy: proxyConfig,
40
},
41
},
42
}, versions.Manifest{
43
Components: versions.Components{
44
PublicAPIServer: versions.Versioned{
45
Version: "commit-test-latest",
46
},
47
},
48
}, "test-namespace")
49
require.NoError(t, err)
50
51
return ctx
52
}
53
54