-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathps_test.go
More file actions
42 lines (34 loc) · 994 Bytes
/
ps_test.go
File metadata and controls
42 lines (34 loc) · 994 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 api
import (
"sort"
"testing"
)
func TestPodsListSorted(t *testing.T) {
pods := PodsList{
{"", "web", "web.fsdfgh4", "up", "1/1", 0, ""},
{"", "web", "web.asdfgh1", "up", "1/1", 0, ""},
{"", "web", "web.csdfgh3", "up", "1/1", 0, ""},
{"", "web", "web.bsdfgh2", "up", "1/1", 0, ""},
}
sort.Sort(pods)
expectedPodNames := []string{"web.asdfgh1", "web.bsdfgh2", "web.csdfgh3", "web.fsdfgh4"}
for i, pod := range pods {
if expectedPodNames[i] != pod.Name {
t.Errorf("Expected pods to be sorted %v, Got %v", expectedPodNames[i], pod.Name)
}
}
}
func TestPodTypesSorted(t *testing.T) {
podTypes := PodTypes{
{"worker", PodsList{}},
{"web", PodsList{}},
{"clock", PodsList{}},
}
sort.Sort(podTypes)
expectedPodTypes := []string{"clock", "web", "worker"}
for i, podType := range podTypes {
if expectedPodTypes[i] != podType.Ptype {
t.Errorf("Expected pod types to be sorted %v, Got %v at index %v", expectedPodTypes[i], podType.Ptype, i)
}
}
}