-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
testclient.go
30 lines (26 loc) · 988 Bytes
/
testclient.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
package testclient
import (
"k8s.io/apimachinery/pkg/runtime"
clientgotesting "k8s.io/client-go/testing"
kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
"github.com/openshift/origin/pkg/client"
)
// NewFixtureClients returns mocks of the OpenShift and Kubernetes clients
// with data populated from provided path.
func NewFixtureClients(objs ...runtime.Object) (client.Interface, kclientset.Interface) {
oc := NewSimpleFake(objs...)
kc := fake.NewSimpleClientset(objs...)
return oc, kc
}
func NewErrorClients(err error) (client.Interface, kclientset.Interface) {
oc := &Fake{}
oc.PrependReactor("*", "*", func(action clientgotesting.Action) (bool, runtime.Object, error) {
return true, nil, err
})
kc := &fake.Clientset{}
kc.PrependReactor("*", "*", func(action clientgotesting.Action) (bool, runtime.Object, error) {
return true, nil, err
})
return oc, kc
}