Skip to content

Commit 759eefa

Browse files
committed
fix: some asserts fixes
1 parent 420ad10 commit 759eefa

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

listener/apischema/builder_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ func TestWithCRDCategories(t *testing.T) {
202202
assert.True(t, found, "expected CategoriesExtensionKey to be set")
203203
cats, ok := ext.([]string)
204204
assert.True(t, ok, "categories should be []string")
205+
assert.Equal(t, len(tc.wantCats), len(cats))
205206
assert.Equal(t, tc.wantCats, cats, "categories mismatch")
206207
})
207208
}
@@ -250,6 +251,7 @@ func TestWithApiResourceCategories(t *testing.T) {
250251
assert.True(t, found, "expected CategoriesExtensionKey to be set")
251252
cats, ok := ext.([]string)
252253
assert.True(t, ok, "categories should be []string")
254+
assert.Equal(t, len(tc.wantCats), len(cats))
253255
assert.Equal(t, tc.wantCats, cats, "categories mismatch")
254256
})
255257
}
@@ -283,7 +285,6 @@ func TestWithScope(t *testing.T) {
283285
b.WithScope(mapper)
284286

285287
// Validate
286-
scope, ok := b.schemas["g.v1.K"].VendorExtensible.Extensions[common.ScopeExtensionKey]
287-
assert.True(t, ok, "expected ScopeExtensionKey to be set")
288+
scope := b.schemas["g.v1.K"].VendorExtensible.Extensions[common.ScopeExtensionKey]
288289
assert.Equal(t, apiextensionsv1.NamespaceScoped, scope, "scope value mismatch")
289290
}

listener/apischema/crd_resolver_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ func TestGetCRDGroupKindVersions(t *testing.T) {
6161
gkv := getCRDGroupKindVersions(tc.spec)
6262
assert.Equal(t, tc.wantG, gkv.Group, "Group mismatch")
6363
assert.Equal(t, tc.wantKind, gkv.Kind, "Kind mismatch")
64+
assert.Equal(t, len(tc.wantVers), len(gkv.Versions), "Versions length mismatch")
6465
assert.Equal(t, tc.wantVers, gkv.Versions, "Versions mismatch")
6566
})
6667
}
@@ -169,7 +170,8 @@ func TestErrorIfCRDNotInPreferredApiGroups(t *testing.T) {
169170
return
170171
}
171172
assert.NoError(t, err)
172-
assert.Equal(t, tc.wantGroup, groups, "groups mismatch")
173+
assert.Equal(t, len(tc.wantGroup), len(groups))
174+
assert.Equal(t, tc.wantGroup, groups)
173175
})
174176
}
175177
}

listener/apischema/json_converter_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ func TestConvertJSON_Transforms(t *testing.T) {
4848
var got, want map[string]any
4949
assert.NoError(t, json.Unmarshal(out, &got), "unmarshal output")
5050
assert.NoError(t, json.Unmarshal([]byte(expected), &want), "unmarshal expected")
51+
assert.Equal(t, len(want), len(got), "output length mismatch")
5152
assert.Equal(t, want, got, "output mismatch")
5253
}

0 commit comments

Comments
 (0)