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

Function TestEventfNoNamespace

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

Source from the content-addressed store, hash-verified

530}
531
532func TestEventfNoNamespace(t *testing.T) {
533 testPod := &v1.Pod{
534 ObjectMeta: metav1.ObjectMeta{
535 SelfLink: "/api/version/pods/foo",
536 Name: "foo",
537 UID: "bar",
538 },
539 }
540 testRef, err := ref.GetPartialReference(scheme.Scheme, testPod, "spec.containers[2]")
541 if err != nil {
542 t.Fatal(err)
543 }
544 table := []struct {
545 obj k8sruntime.Object
546 eventtype string
547 reason string
548 messageFmt string
549 elements []interface{}
550 expect *v1.Event
551 expectLog string
552 expectUpdate bool
553 }{
554 {
555 obj: testRef,
556 eventtype: v1.EventTypeNormal,
557 reason: "Started",
558 messageFmt: "some verbose message: %v",
559 elements: []interface{}{1},
560 expect: &v1.Event{
561 ObjectMeta: metav1.ObjectMeta{
562 Name: "foo",
563 Namespace: "default",
564 },
565 InvolvedObject: v1.ObjectReference{
566 Kind: "Pod",
567 Name: "foo",
568 Namespace: "",
569 UID: "bar",
570 APIVersion: "version",
571 FieldPath: "spec.containers[2]",
572 },
573 Reason: "Started",
574 Message: "some verbose message: 1",
575 Source: v1.EventSource{Component: "eventTest"},
576 Count: 1,
577 Type: v1.EventTypeNormal,
578 },
579 expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
580 expectUpdate: false,
581 },
582 }
583
584 testCache := map[string]*v1.Event{}
585 logCalled := make(chan struct{})
586 createEvent := make(chan *v1.Event)
587 updateEvent := make(chan *v1.Event)
588 patchEvent := make(chan *v1.Event)
589 testEvents := testEventSink{

Callers

nothing calls this directly

Calls 11

OnCreateFactoryFunction · 0.85
OnPatchFactoryFunction · 0.85
NewBroadcasterForTestsFunction · 0.85
recorderWithFakeClockFunction · 0.85
validateEventFunction · 0.85
StartRecordingToSinkMethod · 0.65
NowMethod · 0.65
StartLoggingMethod · 0.65
ErrorfMethod · 0.65
EventfMethod · 0.65
StopMethod · 0.65

Tested by

no test coverage detected