forked from tilt-dev/tilt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfake_test.go
53 lines (46 loc) · 972 Bytes
/
fake_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
package k8s
import (
"fmt"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// Common fakes
var resourceVersion = 1
func fakePod(podID PodID, imageID string) *v1.Pod {
resourceVersion++
return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: string(podID),
Namespace: "default",
Labels: make(map[string]string),
ResourceVersion: fmt.Sprintf("%d", resourceVersion),
},
Spec: v1.PodSpec{
NodeName: "node1",
Containers: []v1.Container{
v1.Container{
Name: "default",
Image: imageID,
},
},
},
}
}
func fakeService(name string) *v1.Service {
return &v1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: "default",
},
}
}
func fakeEvent(name string, message string, count int) *v1.Event {
return &v1.Event{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: "default",
},
Message: message,
Count: int32(count),
}
}