forked from openshift/origin
/
fake_policies.go
45 lines (36 loc) · 1.5 KB
/
fake_policies.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package testclient
import (
ktestclient "k8s.io/kubernetes/pkg/client/testclient"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/watch"
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
)
// FakePolicies implements PolicyInterface. Meant to be embedded into a struct to get a default
// implementation. This makes faking out just the methods you want to test easier.
type FakePolicies struct {
Fake *Fake
Namespace string
}
func (c *FakePolicies) Get(name string) (*authorizationapi.Policy, error) {
obj, err := c.Fake.Invokes(ktestclient.NewGetAction("policies", c.Namespace, name), &authorizationapi.Policy{})
if obj == nil {
return nil, err
}
return obj.(*authorizationapi.Policy), err
}
func (c *FakePolicies) List(label labels.Selector, field fields.Selector) (*authorizationapi.PolicyList, error) {
obj, err := c.Fake.Invokes(ktestclient.NewListAction("policies", c.Namespace, label, field), &authorizationapi.PolicyList{})
if obj == nil {
return nil, err
}
return obj.(*authorizationapi.PolicyList), err
}
func (c *FakePolicies) Delete(name string) error {
_, err := c.Fake.Invokes(ktestclient.NewDeleteAction("policies", c.Namespace, name), &authorizationapi.Policy{})
return err
}
func (c *FakePolicies) Watch(label labels.Selector, field fields.Selector, resourceVersion string) (watch.Interface, error) {
c.Fake.Invokes(ktestclient.NewWatchAction("policies", c.Namespace, label, field, resourceVersion), nil)
return c.Fake.Watch, nil
}