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

Function TestEventf

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

Source from the content-addressed store, hash-verified

103}
104
105func TestEventf(t *testing.T) {
106 testPod := &v1.Pod{
107 ObjectMeta: metav1.ObjectMeta{
108 SelfLink: "/api/version/pods/foo",
109 Name: "foo",
110 Namespace: "baz",
111 UID: "bar",
112 },
113 }
114 testPod2 := &v1.Pod{
115 ObjectMeta: metav1.ObjectMeta{
116 SelfLink: "/api/version/pods/foo",
117 Name: "foo",
118 Namespace: "baz",
119 UID: "differentUid",
120 },
121 }
122 testRef, err := ref.GetPartialReference(scheme.Scheme, testPod, "spec.containers[2]")
123 if err != nil {
124 t.Fatal(err)
125 }
126 testRef2, err := ref.GetPartialReference(scheme.Scheme, testPod2, "spec.containers[3]")
127 if err != nil {
128 t.Fatal(err)
129 }
130 table := []struct {
131 obj k8sruntime.Object
132 eventtype string
133 reason string
134 messageFmt string
135 elements []interface{}
136 expect *v1.Event
137 expectLog string
138 expectUpdate bool
139 }{
140 {
141 obj: testRef,
142 eventtype: v1.EventTypeNormal,
143 reason: "Started",
144 messageFmt: "some verbose message: %v",
145 elements: []interface{}{1},
146 expect: &v1.Event{
147 ObjectMeta: metav1.ObjectMeta{
148 Name: "foo",
149 Namespace: "baz",
150 },
151 InvolvedObject: v1.ObjectReference{
152 Kind: "Pod",
153 Name: "foo",
154 Namespace: "baz",
155 UID: "bar",
156 APIVersion: "version",
157 FieldPath: "spec.containers[2]",
158 },
159 Reason: "Started",
160 Message: "some verbose message: 1",
161 Source: v1.EventSource{Component: "eventTest"},
162 Count: 1,

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