Esempio n. 1
0
func TestEtcdWatch(t *testing.T) {
	storage, _, fakeClient := newStorage(t)
	test := resttest.New(t, storage, fakeClient.SetError)
	test.TestWatch(
		validNewResourceQuota(),
		func() {
			fakeClient.WaitForWatchCompletion()
		},
		func(err error) {
			fakeClient.WatchInjectError <- err
		},
		func(obj runtime.Object, action string) error {
			return registrytest.EmitObject(fakeClient, obj, action)
		},
		// matching labels
		[]labels.Set{},
		// not matching labels
		[]labels.Set{
			{"foo": "bar"},
		},
		// matching fields
		[]fields.Set{
			{"metadata.name": "foo"},
		},
		// not matchin fields
		[]fields.Set{
			{"metadata.name": "bar"},
		},
		registrytest.WatchActions,
	)
}
Esempio n. 2
0
func TestWatchControllers(t *testing.T) {
	storage, fakeClient := newStorage(t)
	test := resttest.New(t, storage, fakeClient.SetError)
	test.TestWatch(
		validController,
		func() {
			fakeClient.WaitForWatchCompletion()
		},
		func(err error) {
			fakeClient.WatchInjectError <- err
		},
		func(obj runtime.Object, action string) error {
			return registrytest.EmitObject(fakeClient, obj, action)
		},
		// matching labels
		[]labels.Set{
			{"a": "b"},
		},
		// not matching labels
		[]labels.Set{
			{"a": "c"},
			{"foo": "bar"},
		},
		// matching fields
		[]fields.Set{
			{"status.replicas": "0"},
			{"metadata.name": "foo"},
			{"status.replicas": "0", "metadata.name": "foo"},
		},
		// not matchin fields
		[]fields.Set{
			{"status.replicas": "10"},
			{"metadata.name": "bar"},
			{"name": "foo"},
			{"status.replicas": "10", "metadata.name": "foo"},
			{"status.replicas": "0", "metadata.name": "bar"},
		},
		registrytest.WatchActions,
	)
}