@@ -83,6 +83,7 @@ func TestReconcile_delete_consolelink(t *testing.T) {
83
83
name string
84
84
setEnvVarFunc func (* testing.T , string )
85
85
envVar string
86
+ consoleLinkPrevExist bool
86
87
consoleLinkShouldExist bool
87
88
wantErr bool
88
89
Err error
@@ -92,6 +93,17 @@ func TestReconcile_delete_consolelink(t *testing.T) {
92
93
setEnvVarFunc : func (t * testing.T , envVar string ) {
93
94
t .Setenv (disableArgoCDConsoleLink , envVar )
94
95
},
96
+ consoleLinkPrevExist : true ,
97
+ consoleLinkShouldExist : false ,
98
+ envVar : "true" ,
99
+ wantErr : false ,
100
+ },
101
+ {
102
+ name : "DISABLE_DEFAULT_ARGOCD_CONSOLELINK is set to true and consoleLink doesn't exist previously" ,
103
+ setEnvVarFunc : func (t * testing.T , envVar string ) {
104
+ t .Setenv (disableArgoCDConsoleLink , envVar )
105
+ },
106
+ consoleLinkPrevExist : false ,
95
107
consoleLinkShouldExist : false ,
96
108
envVar : "true" ,
97
109
wantErr : false ,
@@ -102,13 +114,15 @@ func TestReconcile_delete_consolelink(t *testing.T) {
102
114
t .Setenv (disableArgoCDConsoleLink , envVar )
103
115
},
104
116
envVar : "false" ,
117
+ consoleLinkPrevExist : true ,
105
118
consoleLinkShouldExist : true ,
106
119
wantErr : false ,
107
120
},
108
121
{
109
122
name : "DISABLE_DEFAULT_ARGOCD_CONSOLELINK isn't set and consoleLink doesn't get deleted" ,
110
123
setEnvVarFunc : nil ,
111
124
envVar : "" ,
125
+ consoleLinkPrevExist : true ,
112
126
consoleLinkShouldExist : true ,
113
127
wantErr : false ,
114
128
},
@@ -118,8 +132,10 @@ func TestReconcile_delete_consolelink(t *testing.T) {
118
132
t .Run (test .name , func (t * testing.T ) {
119
133
reconcileArgoCD , fakeClient := newFakeReconcileArgoCD (argoCDRoute , consoleLink )
120
134
consoleLink := newConsoleLink ("https://test.com" , "Cluster Argo CD" )
121
- err := fakeClient .Create (context .TODO (), consoleLink )
122
- assert .NilError (t , err )
135
+ if test .consoleLinkPrevExist {
136
+ err := fakeClient .Create (context .TODO (), consoleLink )
137
+ assert .NilError (t , err )
138
+ }
123
139
124
140
if test .setEnvVarFunc != nil {
125
141
test .setEnvVarFunc (t , test .envVar )
0 commit comments