This repository was archived by the owner on Feb 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkubernetes_test.go
More file actions
69 lines (62 loc) · 1.34 KB
/
kubernetes_test.go
File metadata and controls
69 lines (62 loc) · 1.34 KB
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
66
67
68
69
package main
import (
"testing"
"k8s.io/api/core/v1"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
)
var (
clientset *Clientset
)
func init() {
kubeclientset := fake.NewSimpleClientset(
&v1.EndpointsList{
Items: []v1.Endpoints{
v1.Endpoints{
ObjectMeta: meta_v1.ObjectMeta{
Name: "tiller",
Namespace: "kube-system",
},
Subsets: []v1.EndpointSubset{
v1.EndpointSubset{
Addresses: []v1.EndpointAddress{
v1.EndpointAddress{
IP: "127.0.0.1",
},
},
Ports: []v1.EndpointPort{
v1.EndpointPort{
Port: 8080,
},
},
},
},
},
},
},
)
clientset = &Clientset{
Interface: kubeclientset,
}
}
func TestNewKubeClient(t *testing.T) {
clientset, err := NewKubeClient("./testdata/kubeconfig", "", "local")
if err != nil {
t.Fatal(err)
}
if clientset == (&Clientset{}) {
t.Errorf("Unexpected return from NewKubeClient() : %q", clientset)
}
}
func TestGetEndpoint(t *testing.T) {
endpoints, err := clientset.GetEndpoints("kube-system", "tiller")
if err != nil {
t.Fatal(err)
}
if len(endpoints) != 1 {
t.Errorf("Unexpected return from GetEndpoints() : %q", endpoints)
}
if endpoints[0] != "127.0.0.1:8080" {
t.Errorf("Unexpected return from GetEndpoints() : %q", endpoints)
}
}