@@ -19,6 +19,7 @@ import (
19
19
)
20
20
21
21
type deepLinkTC struct {
22
+ name string
22
23
appObj * unstructured.Unstructured
23
24
clusterObj * unstructured.Unstructured
24
25
resourceObj * unstructured.Unstructured
@@ -70,6 +71,7 @@ func TestDeepLinks(t *testing.T) {
70
71
require .NoError (t , err )
71
72
testTable := []deepLinkTC {
72
73
{
74
+ name : "link to git repo per cluster" ,
73
75
appObj : appObj ,
74
76
resourceObj : resourceObj ,
75
77
projectObj : projectObj ,
@@ -86,6 +88,7 @@ func TestDeepLinks(t *testing.T) {
86
88
error : []string {},
87
89
},
88
90
{
91
+ name : "link to git repo per cluster with abbreviated name" ,
89
92
appObj : appObj ,
90
93
resourceObj : resourceObj ,
91
94
projectObj : projectObj ,
@@ -102,6 +105,7 @@ func TestDeepLinks(t *testing.T) {
102
105
error : []string {},
103
106
},
104
107
{
108
+ name : "condition on missing key" ,
105
109
appObj : appObj ,
106
110
resourceObj : resourceObj ,
107
111
projectObj : projectObj ,
@@ -126,9 +130,10 @@ func TestDeepLinks(t *testing.T) {
126
130
Title : ptr .To ("link" ),
127
131
Url : ptr .To ("http://example.com/test&testns" ),
128
132
}},
129
- error : []string {"failed to evaluate link condition 'application.metadata.test matches \" test \" ' with resource test, error=interface conversion: interface {} is nil, not string (1:27) \n | application.metadata.test matches \" test \" \n | ..........................^" },
133
+ error : []string {}, // expr-lang was updated to handle matches against nil
130
134
},
131
135
{
136
+ name : "condition on invalid expression" ,
132
137
appObj : appObj ,
133
138
resourceObj : resourceObj ,
134
139
projectObj : projectObj ,
@@ -151,6 +156,7 @@ func TestDeepLinks(t *testing.T) {
151
156
error : []string {"link condition '1 + 1' evaluated to non-boolean value for resource test" },
152
157
},
153
158
{
159
+ name : "condition on app and project name" ,
154
160
appObj : appObj ,
155
161
resourceObj : resourceObj ,
156
162
projectObj : projectObj ,
@@ -169,9 +175,13 @@ func TestDeepLinks(t *testing.T) {
169
175
}
170
176
171
177
for _ , tc := range testTable {
172
- objs := CreateDeepLinksObject (tc .resourceObj , tc .appObj , tc .clusterObj , tc .projectObj )
173
- output , err := EvaluateDeepLinksResponse (objs , tc .appObj .GetName (), tc .inputLinks )
174
- assert .Equal (t , tc .error , err , strings .Join (err , "," ))
175
- assert .True (t , reflect .DeepEqual (output .Items , tc .outputLinks ))
178
+ tcc := tc
179
+ t .Run (tc .name , func (t * testing.T ) {
180
+ t .Parallel ()
181
+ objs := CreateDeepLinksObject (tcc .resourceObj , tcc .appObj , tcc .clusterObj , tcc .projectObj )
182
+ output , err := EvaluateDeepLinksResponse (objs , tcc .appObj .GetName (), tcc .inputLinks )
183
+ assert .Equal (t , tcc .error , err , strings .Join (err , "," ))
184
+ assert .True (t , reflect .DeepEqual (output .Items , tcc .outputLinks ))
185
+ })
176
186
}
177
187
}
0 commit comments