Skip to content

Commit

Permalink
Add test for proxy ip configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Farries authored and roboquat committed May 4, 2022
1 parent 2308e17 commit 1d2bae1
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions install/installer/pkg/components/proxy/service_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
// Licensed under the MIT License. See License-MIT.txt in the project root for license information.

package proxy

import (
"testing"

"github.com/gitpod-io/gitpod/installer/pkg/common"
"github.com/gitpod-io/gitpod/installer/pkg/config/v1"
"github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental"
"github.com/gitpod-io/gitpod/installer/pkg/config/versions"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
)

func TestServiceLoadBalancerIP(t *testing.T) {
const loadBalancerIP = "123.456.789.0"
ctx := renderContextWithLoadBalancerIP(t, loadBalancerIP)

objects, err := service(ctx)
require.NoError(t, err)

require.Len(t, objects, 1, "must render only one object")

svc := objects[0].(*corev1.Service)
require.Equal(t, loadBalancerIP, svc.Spec.LoadBalancerIP)
}

func renderContextWithLoadBalancerIP(t *testing.T, loadBalancerIp string) *common.RenderContext {
ctx, err := common.NewRenderContext(config.Config{
Experimental: &experimental.Config{
WebApp: &experimental.WebAppConfig{
ProxyConfig: &experimental.ProxyConfig{
StaticIP: loadBalancerIp,
},
},
},
}, versions.Manifest{
Components: versions.Components{
PublicAPIServer: versions.Versioned{
Version: "commit-test-latest",
},
},
}, "test-namespace")
require.NoError(t, err)

return ctx
}

0 comments on commit 1d2bae1

Please sign in to comment.