-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmux_test.go
49 lines (41 loc) · 1.05 KB
/
tmux_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
package main
import "testing"
func sessionsEqual(a Session, b Session) bool {
return a.Name == b.Name && a.Windows == b.Windows && a.Attached == b.Attached
}
func TestCompilePattern(t *testing.T) {
_, err := compilePattern()
if err != nil {
t.Errorf("Compiling the pattern failed: %s", err)
}
}
func TestParseSessions(t *testing.T) {
fixture := []string{
"fo1o(0): 1 windows (yee datez u know) [50x10]",
"b_a-r$: 2 windows (some date) [100x20] (attached)",
""}
expected := []Session{
Session{
Name: "fo1o(0)",
Windows: 1,
Attached: false},
Session{
Name: "b_a-r$",
Windows: 2,
Attached: true}}
r, _ := compilePattern()
received := parseSessions(fixture, r)
if len(received) != len(expected) {
t.Errorf("Parsed sessions are incorrect, expecteded %d entries, received %d.",
len(expected),
len(received))
} else {
for i := range received {
if !sessionsEqual(expected[i], received[i]) {
t.Errorf("Sessions do not equal:\nExpected: %v\nReceived: %v\n",
expected[i],
received[i])
}
}
}
}