-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
65 lines (58 loc) · 1.79 KB
/
main_test.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
58
59
60
61
62
63
64
65
package main
import (
"testing"
"github.com/nov1n/kubernetes-workflow/pkg/api"
k8sApi "k8s.io/kubernetes/pkg/api"
k8sApiExt "k8s.io/kubernetes/pkg/apis/extensions"
)
func newThirdPartyResourceList(num int) []k8sApiExt.ThirdPartyResource {
tpr := k8sApiExt.ThirdPartyResource{
ObjectMeta: k8sApi.ObjectMeta{
Name: api.Resource + "." + api.Group,
},
Description: api.Description,
Versions: api.Versions,
}
var list []k8sApiExt.ThirdPartyResource
for i := 0; i < num; i++ {
list = append(list, tpr)
}
return list
}
// TODO: Implement this when kube fake client supports tpr.
func TestRegisterThirdPartyResource(t *testing.T) {
// tprs := newThirdPartyResourceList(1)
// tpr := k8sApiExt.ThirdPartyResource{
// ObjectMeta: k8sApi.ObjectMeta{
// Name: api.Resource + "." + api.Group,
// },
// Description: api.Description,
// Versions: api.Versions,
// }
// clientset := fake.NewSimpleClientset(&tpr)
//
// err := registerThirdPartyResource(clientset)
// if err != nil {
// t.Errorf("Didn't expect an error but encountered: %v", err)
// }
// }
// func TestRegisterThirdPartyResourceTwoExistingSucces(t *testing.T) {
// tprs := newThirdPartyResourceList(2)
// tprs[1].Name = "OtherKind"
// clientset := fake.NewSimpleClientset(&tprs[0], &tprs[1])
//
// err := registerThirdPartyResource(clientset)
// if err != nil {
// t.Errorf("Didn't expect an error but encountered: %v", err)
// }
// }
//
// func TestRegisterThirdPartyResourceTwoExistingFail(t *testing.T) {
// tprs := newThirdPartyResourceList(2)
// clientset := fake.NewSimpleClientset(&tprs[0], &tprs[1])
//
// err := registerThirdPartyResource(clientset)
// if err == nil {
// t.Errorf("Expected error because two instances of the same third party resource already exist.")
// }
}