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 Mar 5, 2024
1 parent abf81ab commit 8505155
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
4 changes: 0 additions & 4 deletions pkg/cluster/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ func (s *ToolchainClusterService) addToolchainCluster(log logr.Logger, toolchain
ClusterStatus: &toolchainCluster.Status,
}

if cluster.OperatorNamespace == "" {
return fmt.Errorf("the operator namespace is not set for the ToolchainCluster CR")
}

clusterCache.addCachedToolchainCluster(cluster)
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/cluster/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ func TestListToolchainClusterConfigs(t *testing.T) {

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

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

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

Expand Down
13 changes: 3 additions & 10 deletions pkg/test/verify/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ func AddToolchainClusterAsMember(t *testing.T, functionToVerify FunctionToVerify
cachedToolchainCluster, ok := cluster.GetCachedToolchainCluster("east")
require.True(t, ok)

if labels["namespace"] == "" {
assert.Equal(t, "toolchain-member-operator", cachedToolchainCluster.OperatorNamespace)
} else {
assert.Equal(t, labels["namespace"], cachedToolchainCluster.OperatorNamespace)
}
assert.Equal(t, labels["namespace"], cachedToolchainCluster.OperatorNamespace)

// check that toolchain cluster role label tenant was set only on member cluster type
require.NoError(t, cl.Get(context.TODO(), client.ObjectKeyFromObject(toolchainCluster), toolchainCluster))
Expand Down Expand Up @@ -89,11 +85,8 @@ func AddToolchainClusterAsHost(t *testing.T, functionToVerify FunctionToVerify)
require.NoError(t, err)
cachedToolchainCluster, ok := cluster.GetCachedToolchainCluster("east")
require.True(t, ok)
if labels["namespace"] == "" {
assert.Equal(t, "toolchain-host-operator", cachedToolchainCluster.OperatorNamespace)
} else {
assert.Equal(t, labels["namespace"], cachedToolchainCluster.OperatorNamespace)
}

assert.Equal(t, labels["namespace"], cachedToolchainCluster.OperatorNamespace)

// check that toolchain cluster role label tenant is not set on host cluster
require.NoError(t, cl.Get(context.TODO(), client.ObjectKeyFromObject(toolchainCluster), toolchainCluster))
Expand Down

0 comments on commit 8505155

Please sign in to comment.