Skip to content

Commit cb73bba

Browse files
structwalk: drop the upper-bound field-count assertion that churns on SDK bumps (#5778)
Co-authored-by: Jan N Rose <janniklas.rose@gmail.com>
1 parent 1b3a889 commit cb73bba

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

libs/structs/structwalk/walktype_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,14 @@ func TestTypeSelf(t *testing.T) {
9191
}, getScalarFields(t, reflect.TypeFor[Self]()))
9292
}
9393

94-
func testStruct(t *testing.T, typ reflect.Type, minLen, maxLen int, present map[string]any, notPresent []string) {
94+
func testStruct(t *testing.T, typ reflect.Type, minLen int, present map[string]any, notPresent []string) {
9595
results := getScalarFields(t, typ)
9696

97+
// Only assert a lower bound on the field count: SDK bumps regularly add fields,
98+
// so an upper bound churns every few bumps without catching anything. A runaway
99+
// walk (e.g. circular references failing to terminate) is caught precisely by the
100+
// notPresent checks below instead.
97101
assert.Greater(t, len(results), minLen, "Expected to find many fields in %s", typ)
98-
assert.Less(t, len(results), maxLen, "Expected to find not so many fields in %s", typ)
99102

100103
for path, expectedValue := range present {
101104
value, found := results[path]
@@ -113,7 +116,7 @@ func TestTypeJobSettings(t *testing.T) {
113116
testStruct(t,
114117
reflect.TypeFor[jobs.JobSettings](),
115118
// Verify we found a reasonable number of fields (605 after SDK v0.136.0 bump)
116-
500, 650,
119+
500,
117120
map[string]any{
118121
"name": "",
119122
"timeout_seconds": 0,
@@ -136,7 +139,7 @@ func TestTypeJobSettings(t *testing.T) {
136139
func TestTypeRoot(t *testing.T) {
137140
testStruct(t,
138141
reflect.TypeFor[config.Root](),
139-
5000, 6000, // 5813 after genie_space resource added
142+
5000,
140143
map[string]any{
141144
"bundle.target": "",
142145
`variables.*.lookup.dashboard`: "",

0 commit comments

Comments
 (0)