MCPcopy Index your code
hub / github.com/docker/docker-agent / assertEventsEqual

Function assertEventsEqual

pkg/runtime/runtime_test.go:266–282  ·  view source on GitHub ↗

assertEventsEqual compares two event slices, ignoring timestamps. Timestamps are inherently non-deterministic in tests.

(t *testing.T, expected, actual []Event)

Source from the content-addressed store, hash-verified

264// assertEventsEqual compares two event slices, ignoring timestamps.
265// Timestamps are inherently non-deterministic in tests.
266func assertEventsEqual(t *testing.T, expected, actual []Event) {
267 t.Helper()
268
269 require.Len(t, actual, len(expected), "event count mismatch")
270
271 for i := range expected {
272 expectedType := reflect.TypeOf(expected[i])
273 actualType := reflect.TypeOf(actual[i])
274 assert.Equal(t, expectedType, actualType, "event type mismatch at index %d", i)
275
276 // Clear timestamps for comparison
277 clearTimestamps(expected[i])
278 clearTimestamps(actual[i])
279
280 assert.Equal(t, expected[i], actual[i], "event content mismatch at index %d", i)
281 }
282}
283
284// clearTimestamps sets Timestamp fields to zero value in events for comparison.
285func clearTimestamps(event Event) {

Callers 5

TestSimpleFunction · 0.85
TestWithReasoningFunction · 0.85
TestEmitStartupInfoFunction · 0.85

Calls 2

clearTimestampsFunction · 0.85
LenMethod · 0.65

Tested by

no test coverage detected