-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathps_test.go
More file actions
44 lines (35 loc) · 1.01 KB
/
ps_test.go
File metadata and controls
44 lines (35 loc) · 1.01 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
package api
import (
"sort"
"testing"
"github.com/deis/controller-sdk-go/pkg/time"
)
func TestPodsListSorted(t *testing.T) {
pods := PodsList{
{"", "web", "web.fsdfgh4", "up", time.Time{}},
{"", "web", "web.asdfgh1", "up", time.Time{}},
{"", "web", "web.csdfgh3", "up", time.Time{}},
{"", "web", "web.bsdfgh2", "up", time.Time{}},
}
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.Type {
t.Errorf("Expected pod types to be sorted %v, Got %v at index %v", expectedPodTypes[i], podType.Type, i)
}
}
}