Refactor scheduler factory test

Use `k8s.io/client-go/kubernetes/fake.Clientset` as the fake k8s client.

Signed-off-by: He Xiaoxi <xxhe@alauda.io>

Kubernetes-commit: a96a390d924d33ba7dda13761ff0eb1eb37a02b6
This commit is contained in:
He Xiaoxi
2018-10-02 23:46:17 +08:00
committed by Kubernetes Publisher
parent 7571b2924a
commit da56c29d61

View File

@@ -26,20 +26,31 @@ import (
func (c *FakePods) Bind(binding *v1.Binding) error { func (c *FakePods) Bind(binding *v1.Binding) error {
action := core.CreateActionImpl{} action := core.CreateActionImpl{}
action.Verb = "create" action.Verb = "create"
action.Namespace = binding.Namespace
action.Resource = podsResource action.Resource = podsResource
action.Subresource = "bindings" action.Subresource = "binding"
action.Object = binding action.Object = binding
_, err := c.Fake.Invokes(action, binding) _, err := c.Fake.Invokes(action, binding)
return err return err
} }
func (c *FakePods) GetBinding(name string) (result *v1.Binding, err error) {
obj, err := c.Fake.
Invokes(core.NewGetSubresourceAction(podsResource, c.ns, "binding", name), &v1.Binding{})
if obj == nil {
return nil, err
}
return obj.(*v1.Binding), err
}
func (c *FakePods) GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request { func (c *FakePods) GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request {
action := core.GenericActionImpl{} action := core.GenericActionImpl{}
action.Verb = "get" action.Verb = "get"
action.Namespace = c.ns action.Namespace = c.ns
action.Resource = podsResource action.Resource = podsResource
action.Subresource = "logs" action.Subresource = "log"
action.Value = opts action.Value = opts
_, _ = c.Fake.Invokes(action, &v1.Pod{}) _, _ = c.Fake.Invokes(action, &v1.Pod{})