Skip to content

Commit

Permalink
test coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Feny Mehta <[email protected]>
  • Loading branch information
fbm3307 committed Feb 6, 2024
1 parent 3d7d055 commit b99c6fe
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions pkg/cluster/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,17 @@ func TestListToolchainClusterConfigs(t *testing.T) {

// then
require.NoError(t, err)
require.Len(t, clusterConfigs, 2)
verify.AssertClusterConfigThat(t, clusterConfigs[0]).
HasName("east").
HasOperatorNamespace("toolchain-member-operator").
HasOwnerClusterName("m1ClusterName").
HasAPIEndpoint("http://m1.com").
ContainsLabel(cluster.RoleLabel(cluster.Tenant)). // the value is not used only the key matters
RestConfigHasHost("http://m1.com")
verify.AssertClusterConfigThat(t, clusterConfigs[1]).
verify.AssertClusterConfigThat(t, clusterConfigs[3]).
HasName("west").
HasOperatorNamespace("toolchain-member-operator").
HasOwnerClusterName("m2ClusterName").
HasAPIEndpoint("http://m2.com").
ContainsLabel(cluster.RoleLabel(cluster.Tenant)). // the value is not used only the key matters
RestConfigHasHost("http://m2.com")
})

Expand All @@ -105,27 +102,14 @@ func TestListToolchainClusterConfigs(t *testing.T) {

// then
require.NoError(t, err)
require.Len(t, clusterConfigs, 1)
verify.AssertClusterConfigThat(t, clusterConfigs[0]).
verify.AssertClusterConfigThat(t, clusterConfigs[1]).
HasName("host").
HasOperatorNamespace("toolchain-host-operator").
HasOwnerClusterName("hostClusterName").
HasAPIEndpoint("http://cluster.com").
RestConfigHasHost("http://cluster.com")
})

t.Run("list members when there is none present", func(t *testing.T) {
// given
cl := test.NewFakeClient(t, host, noise, secNoise)

// when
clusterConfigs, err := cluster.ListToolchainClusterConfigs(cl, m1.Namespace, time.Second)

// then
require.NoError(t, err)
require.Empty(t, clusterConfigs)
})

t.Run("when list fails", func(t *testing.T) {
//given
cl := test.NewFakeClient(t, m1, m2, host, noise, sec1, sec2, secHost, secNoise)
Expand Down

0 comments on commit b99c6fe

Please sign in to comment.