func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError).AllowCreateOnUpdate() test.TestUpdate( // valid validService(), func(ctx api.Context, obj runtime.Object) error { return registrytest.SetObject(fakeClient, storage.KeyFunc, ctx, obj) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }, func(ctx api.Context, obj runtime.Object) (runtime.Object, error) { return registrytest.GetObject(fakeClient, storage.KeyFunc, storage.NewFunc, ctx, obj) }, // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.Service) object.Spec = api.ServiceSpec{ Selector: map[string]string{"bar": "baz2"}, SessionAffinity: api.ServiceAffinityNone, Type: api.ServiceTypeClusterIP, Ports: []api.ServicePort{{ Port: 6502, Protocol: api.ProtocolTCP, TargetPort: util.NewIntOrStringFromInt(6502), }}, } return object }, ) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError).AllowCreateOnUpdate() test.TestUpdate( // valid validNewLimitRange(), func(ctx api.Context, obj runtime.Object) error { return registrytest.SetObject(fakeClient, storage.KeyFunc, ctx, obj) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }, func(ctx api.Context, obj runtime.Object) (runtime.Object, error) { return registrytest.GetObject(fakeClient, storage.KeyFunc, storage.NewFunc, ctx, obj) }, // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.LimitRange) object.Spec.Limits = []api.LimitRangeItem{ { Type: api.LimitTypePod, Max: api.ResourceList{ api.ResourceCPU: resource.MustParse("1000"), api.ResourceMemory: resource.MustParse("100000"), }, Min: api.ResourceList{ api.ResourceCPU: resource.MustParse("10"), api.ResourceMemory: resource.MustParse("1000"), }, }, } return object }, ) }
func TestUpdate(t *testing.T) { storage, _, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError).ClusterScope() test.TestUpdate( // valid validNewPersistentVolume("foo"), func(ctx api.Context, obj runtime.Object) error { return registrytest.SetObject(fakeClient, storage.KeyFunc, ctx, obj) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }, func(ctx api.Context, obj runtime.Object) (runtime.Object, error) { return registrytest.GetObject(fakeClient, storage.KeyFunc, storage.NewFunc, ctx, obj) }, // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.PersistentVolume) object.Spec.Capacity = api.ResourceList{ api.ResourceName(api.ResourceStorage): resource.MustParse("20G"), } return object }, ) }
func TestEtcdList(t *testing.T) { storage, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError) key := etcdtest.AddPrefix(storage.KeyRootFunc(test.TestContext())) test.TestList( validNewDeployment(), func(objects []runtime.Object) []runtime.Object { return registrytest.SetObjectsForKey(fakeClient, key, objects) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }) }
func TestList(t *testing.T) { storage, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError) key := etcdtest.AddPrefix(storage.KeyRootFunc(test.TestContext())) autoscaler := validNewHorizontalPodAutoscaler("foo") test.TestList( autoscaler, func(objects []runtime.Object) []runtime.Object { return registrytest.SetObjectsForKey(fakeClient, key, objects) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }) }
func TestList(t *testing.T) { storage, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError).ClusterScope() key := etcdtest.AddPrefix(storage.KeyRootFunc(test.TestContext())) namespace := validNewNamespace() test.TestList( namespace, func(objects []runtime.Object) []runtime.Object { return registrytest.SetObjectsForKey(fakeClient, key, objects) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }) }
func TestEtcdListPersistentVolumeClaims(t *testing.T) { storage, _, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError) key := etcdtest.AddPrefix(storage.KeyRootFunc(test.TestContext())) claim := validNewPersistentVolumeClaim("foo", api.NamespaceDefault) test.TestList( claim, func(objects []runtime.Object) []runtime.Object { return registrytest.SetObjectsForKey(fakeClient, key, objects) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }) }
func TestEtcdList(t *testing.T) { fakeEtcdClient, etcdStorage := newEtcdStorage(t) storage, _ := NewStorage(etcdStorage) test := resttest.New(t, storage, fakeEtcdClient.SetError) key := etcdtest.AddPrefix(storage.Etcd.KeyRootFunc(test.TestContext())) resourcequota := validNewResourceQuota() test.TestList( resourcequota, func(objects []runtime.Object) []runtime.Object { return registrytest.SetObjectsForKey(fakeEtcdClient, key, objects) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeEtcdClient, resourceVersion) }) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError) test.TestUpdate( // valid validNewDeployment(), func(ctx api.Context, obj runtime.Object) error { return registrytest.SetObject(fakeClient, storage.KeyFunc, ctx, obj) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }, func(ctx api.Context, obj runtime.Object) (runtime.Object, error) { return registrytest.GetObject(fakeClient, storage.KeyFunc, storage.NewFunc, ctx, obj) }, // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*expapi.Deployment) object.Spec.Template.Spec.NodeSelector = map[string]string{"c": "d"} return object }, // invalid updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*expapi.Deployment) object.UID = "newUID" return object }, func(obj runtime.Object) runtime.Object { object := obj.(*expapi.Deployment) object.Name = "" return object }, func(obj runtime.Object) runtime.Object { object := obj.(*expapi.Deployment) object.Spec.Template.Spec.RestartPolicy = api.RestartPolicyOnFailure return object }, func(obj runtime.Object) runtime.Object { object := obj.(*expapi.Deployment) object.Spec.Selector = map[string]string{} return object }, ) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError) test.TestUpdate( // valid validNewController(), func(ctx api.Context, obj runtime.Object) error { return registrytest.SetObject(fakeClient, storage.KeyFunc, ctx, obj) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }, func(ctx api.Context, obj runtime.Object) (runtime.Object, error) { return registrytest.GetObject(fakeClient, storage.KeyFunc, storage.NewFunc, ctx, obj) }, // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.ReplicationController) object.Spec.Replicas = object.Spec.Replicas + 1 return object }, // invalid updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.ReplicationController) object.UID = "newUID" return object }, func(obj runtime.Object) runtime.Object { object := obj.(*api.ReplicationController) object.Name = "" return object }, func(obj runtime.Object) runtime.Object { object := obj.(*api.ReplicationController) object.Spec.Selector = map[string]string{} return object }, ) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError) test.TestUpdate( // valid validNewSecret("foo"), func(ctx api.Context, obj runtime.Object) error { return registrytest.SetObject(fakeClient, storage.KeyFunc, ctx, obj) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }, func(ctx api.Context, obj runtime.Object) (runtime.Object, error) { return registrytest.GetObject(fakeClient, storage.KeyFunc, storage.NewFunc, ctx, obj) }, // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.Secret) object.Data["othertest"] = []byte("otherdata") return object }, ) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError).ClusterScope() test.TestUpdate( // valid validNewNode(), func(ctx api.Context, obj runtime.Object) error { return registrytest.SetObject(fakeClient, storage.KeyFunc, ctx, obj) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }, func(ctx api.Context, obj runtime.Object) (runtime.Object, error) { return registrytest.GetObject(fakeClient, storage.KeyFunc, storage.NewFunc, ctx, obj) }, // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.Node) object.Spec.Unschedulable = !object.Spec.Unschedulable return object }, ) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError) test.TestUpdate( // valid validNewServiceAccount("foo"), func(ctx api.Context, obj runtime.Object) error { return registrytest.SetObject(fakeClient, storage.KeyFunc, ctx, obj) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }, func(ctx api.Context, obj runtime.Object) (runtime.Object, error) { return registrytest.GetObject(fakeClient, storage.KeyFunc, storage.NewFunc, ctx, obj) }, // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.ServiceAccount) // TODO: Update this serviceAccount return object }, ) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError) test.TestUpdate( // valid validNewHorizontalPodAutoscaler("foo"), func(ctx api.Context, obj runtime.Object) error { return registrytest.SetObject(fakeClient, storage.KeyFunc, ctx, obj) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }, func(ctx api.Context, obj runtime.Object) (runtime.Object, error) { return registrytest.GetObject(fakeClient, storage.KeyFunc, storage.NewFunc, ctx, obj) }, // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*expapi.HorizontalPodAutoscaler) object.Spec.MaxCount = object.Spec.MaxCount + 1 return object }, ) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError) test.TestUpdate( //valid validNewPodTemplate("foo"), func(ctx api.Context, obj runtime.Object) error { return registrytest.SetObject(fakeClient, storage.KeyFunc, ctx, obj) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }, func(ctx api.Context, obj runtime.Object) (runtime.Object, error) { return registrytest.GetObject(fakeClient, storage.KeyFunc, storage.NewFunc, ctx, obj) }, // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*api.PodTemplate) object.Template.Spec.NodeSelector = map[string]string{"a": "b"} return object }, ) }
func TestUpdate(t *testing.T) { storage, fakeClient := newStorage(t) test := resttest.New(t, storage, fakeClient.SetError) test.TestUpdate( // valid validNewThirdPartyResource("foo"), func(ctx api.Context, obj runtime.Object) error { return registrytest.SetObject(fakeClient, storage.KeyFunc, ctx, obj) }, func(resourceVersion uint64) { registrytest.SetResourceVersion(fakeClient, resourceVersion) }, func(ctx api.Context, obj runtime.Object) (runtime.Object, error) { return registrytest.GetObject(fakeClient, storage.KeyFunc, storage.NewFunc, ctx, obj) }, // updateFunc func(obj runtime.Object) runtime.Object { object := obj.(*expapi.ThirdPartyResource) object.Description = "new description" return object }, ) }