func TestRESTWatch(t *testing.T) { eventA := &api.Event{ InvolvedObject: api.ObjectReference{ Kind: "Pod", Name: "foo", UID: "long uid string", APIVersion: testapi.Version(), ResourceVersion: "0", FieldPath: "", }, Reason: "ForTesting", } reg, rest := NewTestREST() wi, err := rest.Watch(api.NewContext(), labels.Everything(), fields.Everything(), "0") if err != nil { t.Fatalf("Unexpected error %v", err) } go func() { reg.Broadcaster.Action(watch.Added, eventA) }() got := <-wi.ResultChan() if e, a := eventA, got.Object; !reflect.DeepEqual(e, a) { t.Errorf("diff: %s", util.ObjectDiff(e, a)) } }
func TestRESTWatch(t *testing.T) { secretA := testSecret("a") reg, rest := NewTestREST() wi, err := rest.Watch(api.NewContext(), labels.Everything(), fields.Everything(), "0") if err != nil { t.Fatalf("Unexpected error %v", err) } go func() { reg.Broadcaster.Action(watch.Added, secretA) }() got := <-wi.ResultChan() if e, a := secretA, got.Object; !reflect.DeepEqual(e, a) { t.Errorf("diff: %s", util.ObjectDiff(e, a)) } }