MCPcopy
hub / github.com/kubernetes/client-go / TestUpdateExpiredEvent

Function TestUpdateExpiredEvent

tools/record/event_test.go:441–475  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

439}
440
441func TestUpdateExpiredEvent(t *testing.T) {
442 clock := clock.IntervalClock{Time: time.Now(), Duration: time.Second}
443 eventCorrelator := NewEventCorrelator(&clock)
444 randGen := rand.New(rand.NewSource(time.Now().UnixNano()))
445
446 var createdEvent *v1.Event
447
448 sink := &testEventSink{
449 OnPatch: func(*v1.Event, []byte) (*v1.Event, error) {
450 return nil, &errors.StatusError{
451 ErrStatus: metav1.Status{
452 Code: http.StatusNotFound,
453 Reason: metav1.StatusReasonNotFound,
454 }}
455 },
456 OnCreate: func(event *v1.Event) (*v1.Event, error) {
457 createdEvent = event
458 return event, nil
459 },
460 }
461
462 ev := &v1.Event{}
463 ev.ResourceVersion = "updated-resource-version"
464 ev.Count = 2
465 recordToSink(sink, ev, eventCorrelator, randGen, 0)
466
467 if createdEvent == nil {
468 t.Error("Event did not get created after patch failed")
469 return
470 }
471
472 if createdEvent.ResourceVersion != "" {
473 t.Errorf("Event did not have its resource version cleared, was %s", createdEvent.ResourceVersion)
474 }
475}
476
477func TestLotsOfEvents(t *testing.T) {
478 recorderCalled := make(chan struct{})

Callers

nothing calls this directly

Calls 5

NewEventCorrelatorFunction · 0.85
recordToSinkFunction · 0.85
NowMethod · 0.65
ErrorMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected