本文整理匯總了Golang中k8s/io/kubernetes/pkg/registry/registrytest.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了New函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestUpdate
func TestUpdate(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Controller.Store.DestroyFunc()
test := registrytest.New(t, storage.Controller.Store)
test.TestUpdate(
// valid
validNewController(),
// valid 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.Name = ""
return object
},
func(obj runtime.Object) runtime.Object {
object := obj.(*api.ReplicationController)
object.Spec.Selector = map[string]string{}
return object
},
)
}
示例2: TestDelete
func TestDelete(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := registrytest.New(t, storage.Store).ClusterScope().ReturnDeletedObject()
test.TestDelete(validNewPodSecurityPolicy())
}
示例3: TestWatch
func TestWatch(t *testing.T) {
storage, _, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := registrytest.New(t, storage.Store)
test.TestWatch(
validNewPodDisruptionBudget(),
// matching labels
[]labels.Set{
{"a": "b"},
},
// not matching labels
[]labels.Set{
{"a": "c"},
{"foo": "bar"},
},
// matching fields
[]fields.Set{
{"metadata.name": "foo"},
},
// not matching fields
[]fields.Set{
{"metadata.name": "bar"},
},
)
}
示例4: TestWatch
func TestWatch(t *testing.T) {
storage, _, server := newStorage(t)
defer server.Terminate(t)
test := registrytest.New(t, storage.Etcd)
test.TestWatch(
validDaemonSet,
// matching labels
[]labels.Set{
{"a": "b"},
},
// not matching labels
[]labels.Set{
{"a": "c"},
{"foo": "bar"},
},
// matching fields
[]fields.Set{
{"metadata.name": "foo"},
},
// notmatching fields
[]fields.Set{
{"metadata.name": "bar"},
{"name": "foo"},
},
)
}
示例5: TestList
func TestList(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := registrytest.New(t, storage.Store).ClusterScope()
test.TestList(validNewNode())
}
示例6: TestCreate
func TestCreate(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
test := registrytest.New(t, storage.Etcd)
validConfigMap := validNewConfigMap()
validConfigMap.ObjectMeta = api.ObjectMeta{
GenerateName: "foo-",
}
test.TestCreate(
validConfigMap,
&api.ConfigMap{
ObjectMeta: api.ObjectMeta{Name: "badName"},
Data: map[string]string{
"key": "value",
},
},
&api.ConfigMap{
ObjectMeta: api.ObjectMeta{Name: "name-2"},
Data: map[string]string{
"..dotfile": "do: nothing\n",
},
},
)
}
示例7: TestList
func TestList(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := registrytest.New(t, storage.Store)
test.TestList(validNewEndpoints())
}
示例8: TestUpdate
func TestUpdate(t *testing.T) {
storage, _, fakeClient := newStorage(t)
test := registrytest.New(t, fakeClient, storage.Etcd)
two := 2
test.TestUpdate(
// valid
validNewJob(),
// updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*extensions.Job)
object.Spec.Parallelism = &two
return object
},
// invalid updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*extensions.Job)
object.Spec.Selector = map[string]string{}
return object
},
func(obj runtime.Object) runtime.Object {
object := obj.(*extensions.Job)
object.Spec.Completions = &two
return object
},
)
}
示例9: TestDelete
func TestDelete(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := registrytest.New(t, storage.Store)
test.TestDelete(validNewLimitRange())
}
示例10: TestWatch
func TestWatch(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
test := registrytest.New(t, storage.ReplicaSet.Store)
test.TestWatch(
validNewReplicaSet(),
// matching labels
[]labels.Set{
{"a": "b"},
},
// not matching labels
[]labels.Set{
{"a": "c"},
{"foo": "bar"},
},
// matching fields
[]fields.Set{
{"status.replicas": "5"},
{"metadata.name": "foo"},
{"status.replicas": "5", "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"},
},
)
}
示例11: TestUpdate
func TestUpdate(t *testing.T) {
storage, _, server := newStorage(t)
defer server.Terminate(t)
test := registrytest.New(t, storage.Store)
two := int32(2)
test.TestUpdate(
// valid
validNewJob(),
// updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*batch.Job)
object.Spec.Parallelism = &two
return object
},
// invalid updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*batch.Job)
object.Spec.Selector = &unversioned.LabelSelector{}
return object
},
func(obj runtime.Object) runtime.Object {
object := obj.(*batch.Job)
object.Spec.Completions = &two
return object
},
)
}
示例12: TestUpdate
func TestUpdate(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
test := registrytest.New(t, storage.ReplicaSet.Store)
test.TestUpdate(
// valid
validNewReplicaSet(),
// valid updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*extensions.ReplicaSet)
object.Spec.Replicas = object.Spec.Replicas + 1
return object
},
// invalid updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*extensions.ReplicaSet)
object.Name = ""
return object
},
func(obj runtime.Object) runtime.Object {
object := obj.(*extensions.ReplicaSet)
object.Spec.Selector = &unversioned.LabelSelector{MatchLabels: map[string]string{}}
return object
},
)
}
示例13: TestDelete
func TestDelete(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := registrytest.New(t, storage.Store).ClusterScope().Namer(namer)
test.TestDelete(validNewThirdPartyResource("kind.domain.tld"))
}
示例14: TestGet
func TestGet(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Controller.Store.DestroyFunc()
test := registrytest.New(t, storage.Controller.Store)
test.TestGet(validNewController())
}
示例15: TestUpdate
func TestUpdate(t *testing.T) {
storage, _, fakeClient := newStorage(t)
test := registrytest.New(t, fakeClient, storage.Etcd)
test.TestUpdate(
// valid
newValidDaemonSet(),
// updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*experimental.DaemonSet)
object.Spec.Template.Spec.NodeSelector = map[string]string{"c": "d"}
return object
},
// invalid updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*experimental.DaemonSet)
object.UID = "newUID"
return object
},
func(obj runtime.Object) runtime.Object {
object := obj.(*experimental.DaemonSet)
object.Name = ""
return object
},
func(obj runtime.Object) runtime.Object {
object := obj.(*experimental.DaemonSet)
object.Spec.Template.Spec.RestartPolicy = api.RestartPolicyOnFailure
return object
},
func(obj runtime.Object) runtime.Object {
object := obj.(*experimental.DaemonSet)
object.Spec.Selector = map[string]string{}
return object
},
)
}