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

Function clearTimestamps

pkg/runtime/runtime_test.go:285–308  ·  view source on GitHub ↗

clearTimestamps sets Timestamp fields to zero value in events for comparison.

(event Event)

Source from the content-addressed store, hash-verified

283
284// clearTimestamps sets Timestamp fields to zero value in events for comparison.
285func clearTimestamps(event Event) {
286 if event == nil {
287 return
288 }
289
290 // Use reflection to find and clear Timestamp in embedded AgentContext
291 v := reflect.ValueOf(event)
292 if v.Kind() == reflect.Pointer {
293 v = v.Elem()
294 }
295 if v.Kind() != reflect.Struct {
296 return
297 }
298
299 field := v.FieldByName("AgentContext")
300 if !field.IsValid() || field.Kind() != reflect.Struct {
301 return
302 }
303
304 timestampField := field.FieldByName("Timestamp")
305 if timestampField.IsValid() && timestampField.CanSet() {
306 timestampField.Set(reflect.Zero(timestampField.Type()))
307 }
308}
309
310func TestSimple(t *testing.T) {
311 t.Parallel()

Callers 1

assertEventsEqualFunction · 0.85

Calls 4

TypeMethod · 0.80
KindMethod · 0.65
IsValidMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected