mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Add unit test for Recorder
Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
This commit is contained in:
parent
c98b388a84
commit
ebfb5392c5
@ -82,3 +82,33 @@ func TestFilterStop(t *testing.T) {
|
|||||||
t.Errorf("got %v, wanted %v", e, a)
|
t.Errorf("got %v, wanted %v", e, a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRecorder(t *testing.T) {
|
||||||
|
events := []Event{
|
||||||
|
{Type: Added, Object: testType("foo")},
|
||||||
|
{Type: Added, Object: testType("bar")},
|
||||||
|
{Type: Added, Object: testType("baz")},
|
||||||
|
{Type: Added, Object: testType("qux")},
|
||||||
|
{Type: Added, Object: testType("zoo")},
|
||||||
|
}
|
||||||
|
|
||||||
|
source := NewFake()
|
||||||
|
go func() {
|
||||||
|
for _, item := range events {
|
||||||
|
source.Action(item.Type, item.Object)
|
||||||
|
}
|
||||||
|
source.Stop()
|
||||||
|
}()
|
||||||
|
|
||||||
|
recorder := NewRecorder(source)
|
||||||
|
for {
|
||||||
|
_, ok := <-recorder.Interface.ResultChan()
|
||||||
|
if !ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
recordedEvents := recorder.Events()
|
||||||
|
if !reflect.DeepEqual(recordedEvents, events) {
|
||||||
|
t.Errorf("got %v, expected %v", recordedEvents, events)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user