-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfigmap_test.go
More file actions
42 lines (38 loc) · 914 Bytes
/
configmap_test.go
File metadata and controls
42 lines (38 loc) · 914 Bytes
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
package ok8s
import (
"fmt"
apicorev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
"testing"
)
var (
cm = apicorev1.ConfigMap{
ObjectMeta: v1.ObjectMeta{
Name: "web-cm",
},
Data: map[string]string{
"user": "root",
"password": "123456",
},
}
c = NewConfigMap(NewTestClientSet())
)
func TestConfigMap_Create(t *testing.T) {
ok, err := c.Create(ns, cm)
AssertError(ok, err, t)
}
func TestConfigMap_Watch(t *testing.T) {
watchFuncs := cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
fmt.Printf("Create cm %s\n", obj.(*apicorev1.ConfigMap).Name)
},
DeleteFunc: func(obj interface{}) {
fmt.Printf("Delete cm %s\n", obj.(*apicorev1.ConfigMap).Name)
},
UpdateFunc: func(oldObj, newObj interface{}) {
fmt.Printf("Update cm %s\n", oldObj.(*apicorev1.ConfigMap).Name)
},
}
c.Watch(ns, watchFuncs)
}