-
Notifications
You must be signed in to change notification settings - Fork 0
/
miller_test.go
76 lines (64 loc) · 1.79 KB
/
miller_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package miller_test
import (
"testing"
"github.com/davecgh/go-spew/spew"
"github.com/ninjadojo/miller"
)
func TestMiller(t *testing.T) {
spew.Config.Indent = "\t"
columns := miller.NewColumns([]string{"."})
columns.Descend("test")
lastCategory := columns.Categories[len(columns.Categories)-1]
for _, item := range lastCategory.Items {
if item.Name != "child" {
t.Errorf("Expected child, got %s", item.Name)
return
}
}
columns.Descend("child")
lastCategory = columns.Categories[len(columns.Categories)-1]
for _, item := range lastCategory.Items {
if item.Name != "anotherchild" {
t.Errorf("Expected anotherchild, got %s", item.Name)
return
}
}
columns.Descend("anotherchild")
lastCategory = columns.Categories[len(columns.Categories)-1]
if len(lastCategory.Items) != 0 {
t.Errorf("Expected no folders, got %d folders", len(lastCategory.Items))
return
}
columns.Ascend()
lastCategory = columns.Categories[len(columns.Categories)-1]
for _, item := range lastCategory.Items {
if item.Name != "anotherchild" {
t.Errorf("Expected anotherchild, got %s", item.Name)
return
}
}
columns.Ascend()
lastCategory = columns.Categories[len(columns.Categories)-1]
for _, item := range lastCategory.Items {
if item.Name != "child" {
t.Errorf("Expected child, got %s", item.Name)
return
}
}
columns.Ascend()
lastCategory = columns.Categories[len(columns.Categories)-1]
for _, item := range lastCategory.Items {
if item.Name != "test" && item.Name != ".git" {
t.Errorf("Expected child, got %s", item.Name)
return
}
}
columns.Ascend()
lastCategory = columns.Categories[len(columns.Categories)-1]
for _, item := range lastCategory.Items {
if item.Name != "test" && item.Name != ".git" {
t.Errorf("Expected child, got %s", item.Name)
return
}
}
}