Skip to content

Commit f23af32

Browse files
committed
fix test failures
Signed-off-by: Atif Ali <[email protected]>
1 parent 09b7618 commit f23af32

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

server/deeplinks/deeplinks_test.go

+15-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
)
2020

2121
type deepLinkTC struct {
22+
name string
2223
appObj *unstructured.Unstructured
2324
clusterObj *unstructured.Unstructured
2425
resourceObj *unstructured.Unstructured
@@ -70,6 +71,7 @@ func TestDeepLinks(t *testing.T) {
7071
require.NoError(t, err)
7172
testTable := []deepLinkTC{
7273
{
74+
name: "link to git repo per cluster",
7375
appObj: appObj,
7476
resourceObj: resourceObj,
7577
projectObj: projectObj,
@@ -86,6 +88,7 @@ func TestDeepLinks(t *testing.T) {
8688
error: []string{},
8789
},
8890
{
91+
name: "link to git repo per cluster with abbreviated name",
8992
appObj: appObj,
9093
resourceObj: resourceObj,
9194
projectObj: projectObj,
@@ -102,6 +105,7 @@ func TestDeepLinks(t *testing.T) {
102105
error: []string{},
103106
},
104107
{
108+
name: "condition on missing key",
105109
appObj: appObj,
106110
resourceObj: resourceObj,
107111
projectObj: projectObj,
@@ -126,9 +130,10 @@ func TestDeepLinks(t *testing.T) {
126130
Title: ptr.To("link"),
127131
Url: ptr.To("http://example.com/test&testns"),
128132
}},
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
130134
},
131135
{
136+
name: "condition on invalid expression",
132137
appObj: appObj,
133138
resourceObj: resourceObj,
134139
projectObj: projectObj,
@@ -151,6 +156,7 @@ func TestDeepLinks(t *testing.T) {
151156
error: []string{"link condition '1 + 1' evaluated to non-boolean value for resource test"},
152157
},
153158
{
159+
name: "condition on app and project name",
154160
appObj: appObj,
155161
resourceObj: resourceObj,
156162
projectObj: projectObj,
@@ -169,9 +175,13 @@ func TestDeepLinks(t *testing.T) {
169175
}
170176

171177
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+
})
176186
}
177187
}

0 commit comments

Comments
 (0)