Skip to content

Commit ab31168

Browse files
committed
Fix unit tests for clusterinfoupdater
Signed-off-by: Chetan Banavikalmutt <[email protected]>
1 parent 8dde212 commit ab31168

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

controller/clusterinfoupdater_test.go

+20-3
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ func TestClusterSecretUpdater(t *testing.T) {
3636
var tests = []struct {
3737
LastCacheSyncTime *time.Time
3838
SyncError error
39+
ConnectionStatus clustercache.ConnectionStatus
3940
ExpectedStatus v1alpha1.ConnectionStatus
4041
}{
41-
{nil, nil, v1alpha1.ConnectionStatusUnknown},
42-
{&now, nil, v1alpha1.ConnectionStatusSuccessful},
43-
{&now, fmt.Errorf("sync failed"), v1alpha1.ConnectionStatusFailed},
42+
{nil, nil, clustercache.ConnectionStatusUnknown, v1alpha1.ConnectionStatusUnknown},
43+
{&now, nil, clustercache.ConnectionStatusSuccessful, v1alpha1.ConnectionStatusSuccessful},
44+
{&now, fmt.Errorf("sync failed"), clustercache.ConnectionStatusSuccessful, v1alpha1.ConnectionStatusFailed},
45+
{&now, nil, clustercache.ConnectionStatusFailed, v1alpha1.ConnectionStatusFailed},
4446
}
4547

4648
emptyArgoCDConfigMap := &v1.ConfigMap{
@@ -78,12 +80,27 @@ func TestClusterSecretUpdater(t *testing.T) {
7880
cluster, err := argoDB.CreateCluster(ctx, &v1alpha1.Cluster{Server: "http://minikube"})
7981
assert.NoError(t, err, "Test prepare test data create cluster failed")
8082

83+
fakeApp := &v1alpha1.Application{
84+
ObjectMeta: metav1.ObjectMeta{
85+
Name: "fake-app",
86+
Namespace: fakeNamespace,
87+
},
88+
Spec: v1alpha1.ApplicationSpec{
89+
Destination: v1alpha1.ApplicationDestination{
90+
Server: cluster.Server,
91+
},
92+
},
93+
}
94+
err = appInformer.GetIndexer().Add(fakeApp)
95+
assert.NoError(t, err)
96+
8197
for _, test := range tests {
8298
info := &clustercache.ClusterInfo{
8399
Server: cluster.Server,
84100
K8SVersion: updatedK8sVersion,
85101
LastCacheSyncTime: test.LastCacheSyncTime,
86102
SyncError: test.SyncError,
103+
ConnectionStatus: test.ConnectionStatus,
87104
}
88105

89106
lister := applisters.NewApplicationLister(appInformer.GetIndexer()).Applications(fakeNamespace)

0 commit comments

Comments
 (0)