Skip to content

Commit

Permalink
Add test for common.Replicas function
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Farries committed Apr 25, 2022
1 parent b8c2611 commit 939a2e1
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions install/installer/pkg/common/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"

"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/google/go-cmp/cmp"
"github.com/stretchr/testify/require"
Expand All @@ -28,6 +29,46 @@ func TestCompositeRenderFunc_NilObjectsNilError(t *testing.T) {
require.Len(t, objects, 0)
}

func TestReplicas(t *testing.T) {
testCases := []struct {
Component string
ExpectedReplicas int32
}{
{
Component: "server",
ExpectedReplicas: 123,
},
{
Component: "dashboard",
ExpectedReplicas: 456,
},
{
Component: "content-service",
ExpectedReplicas: 1,
},
}
ctx, err := NewRenderContext(config.Config{
Experimental: &experimental.Config{
Common: &experimental.CommonConfig{
PodConfig: map[string]*experimental.PodConfig{
"server": {Replicas: pointer.Int32(123)},
"dashboard": {Replicas: pointer.Int32(456)},
},
},
},
}, versions.Manifest{}, "test_namespace")
require.NoError(t, err)

for _, testCase := range testCases {
actualReplicas := Replicas(ctx, testCase.Component)

if *actualReplicas != testCase.ExpectedReplicas {
t.Errorf("expected %d replicas for %q component, but got %d",
testCase.ExpectedReplicas, testCase.Component, *actualReplicas)
}
}
}

func TestRepoName(t *testing.T) {
type Expectation struct {
Result string
Expand Down

0 comments on commit 939a2e1

Please sign in to comment.