forked from openshift/origin
/
fake_roles.go
57 lines (45 loc) · 1.72 KB
/
fake_roles.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
46
47
48
49
50
51
52
53
54
55
56
57
package testclient
import (
ktestclient "k8s.io/kubernetes/pkg/client/unversioned/testclient"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
authorizationapi "github.com/openshift/origin/pkg/authorization/api"
)
// FakeRoles implements RoleInterface. 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 FakeRoles struct {
Fake *Fake
Namespace string
}
func (c *FakeRoles) Get(name string) (*authorizationapi.Role, error) {
obj, err := c.Fake.Invokes(ktestclient.NewGetAction("roles", c.Namespace, name), &authorizationapi.Role{})
if obj == nil {
return nil, err
}
return obj.(*authorizationapi.Role), err
}
func (c *FakeRoles) List(label labels.Selector, field fields.Selector) (*authorizationapi.RoleList, error) {
obj, err := c.Fake.Invokes(ktestclient.NewListAction("roles", c.Namespace, label, field), &authorizationapi.RoleList{})
if obj == nil {
return nil, err
}
return obj.(*authorizationapi.RoleList), err
}
func (c *FakeRoles) Create(inObj *authorizationapi.Role) (*authorizationapi.Role, error) {
obj, err := c.Fake.Invokes(ktestclient.NewCreateAction("roles", c.Namespace, inObj), inObj)
if obj == nil {
return nil, err
}
return obj.(*authorizationapi.Role), err
}
func (c *FakeRoles) Update(inObj *authorizationapi.Role) (*authorizationapi.Role, error) {
obj, err := c.Fake.Invokes(ktestclient.NewUpdateAction("roles", c.Namespace, inObj), inObj)
if obj == nil {
return nil, err
}
return obj.(*authorizationapi.Role), err
}
func (c *FakeRoles) Delete(name string) error {
_, err := c.Fake.Invokes(ktestclient.NewDeleteAction("roles", c.Namespace, name), &authorizationapi.Role{})
return err
}