Skip to content

Commit ff73a89

Browse files
jensneuseclaude
andcommitted
fix(test): make extensions analytics test tolerant of nil snapshot slice
Three CI fixes: 1. extensions_cache_invalidation_test.go: TestExtensionsCacheInvalidation Analytics/records_no_MutationEvent_when_extension_delete_is_skipped asserted assert.Equal([]MutationEvent{}, stats.MutationEvents). The snapshot's slices.Clone returns nil when the underlying slice is never appended to, so DeepEqual mismatched the empty-slice expected value against the nil actual. Switch to len() == 0, which is exact and tolerates the nil/empty implementation detail. 2. cache_key_parity_test.go: gci import grouping fix per .golangci.yml sections (standard / default / wundergraph / wundergraph/graphql-go-tools). 3. planner_test.go: gofmt -s fix for redundant []int{0} slice literals in the reused-planner regression test. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 923b742 commit ff73a89

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

v2/pkg/engine/plan/planner_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -971,8 +971,8 @@ func TestPlanner_Plan(t *testing.T) {
971971
},
972972
}, costHashes(plan2))
973973
assert.Equal(t, map[int][]int{
974-
0: []int{0},
975-
1: []int{0},
974+
0: {0},
975+
1: {0},
976976
}, sharedPlanner.planningVisitor.fieldPlanners)
977977
})
978978

v2/pkg/engine/resolve/cache_key_parity_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/golang/mock/gomock"
99
"github.com/stretchr/testify/assert"
1010
"github.com/stretchr/testify/require"
11+
1112
"github.com/wundergraph/astjson"
1213
"github.com/wundergraph/go-arena"
1314

v2/pkg/engine/resolve/extensions_cache_invalidation_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,10 @@ func TestExtensionsCacheInvalidationAnalytics(t *testing.T) {
240240
env.run()
241241
stats := env.ctx.GetCacheStats()
242242

243-
assert.Equal(t, []MutationEvent{}, stats.MutationEvents)
243+
// Snapshot's slices.Clone returns nil when the underlying slice is nil
244+
// (no events appended). Assert the count rather than DeepEqual against
245+
// []MutationEvent{}, which would mismatch a nil slice.
246+
assert.Equal(t, 0, len(stats.MutationEvents))
244247
})
245248
}
246249

0 commit comments

Comments
 (0)