-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
config_test.go
60 lines (55 loc) · 1.07 KB
/
config_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
package main
import (
"os"
"reflect"
"testing"
)
func TestParseConfig(t *testing.T) {
yaml := `
session: ${session}
sendkeys_timeout: 200
tmux_options:
socket_name: foo
socket_path: /path/to/socket
config_file: /path/to/tmux_config
windows:
- layout: tiled
commands:
- echo 1
panes:
- commands:
- echo 2
- echo ${HOME}
type: horizontal`
config, err := ParseConfig(yaml, map[string]string{
"session": "test",
})
if err != nil {
t.Fatal(err)
}
expected := Config{
Session: "test",
SendKeysTimeout: 200,
Env: make(map[string]string),
TmuxOptions: TmuxOptions{
SocketName: "foo",
SocketPath: "/path/to/socket",
ConfigFile: "/path/to/tmux_config",
},
Windows: []Window{
{
Layout: "tiled",
Commands: []string{"echo 1"},
Panes: []Pane{
{
Type: "horizontal",
Commands: []string{"echo 2", "echo " + os.Getenv("HOME")},
},
},
},
},
}
if !reflect.DeepEqual(expected, config) {
t.Fatalf("expected %v, got %v", expected, config)
}
}