-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser_test.go
39 lines (35 loc) · 993 Bytes
/
parser_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
package main
import (
"reflect"
"testing"
)
func TestParseDotfiles(t *testing.T) {
fs := MakeMockFilesystem(map[string]string{
"/dotfiles/dotcopy.yaml": `---
- template: template.txt
slotfile: slotfile.txt
location: ~/somewhere/compiledfile.txt`,
"/dotfiles/template.txt": "template text",
"/dotfiles/machine/slotfile.txt": "slot text",
})
dotfiles, err := ParseDotfiles(fs, LocalConfig{
RootFilepath: "/dotfiles",
MachineDirectory: "machine",
})
if err != nil {
t.Errorf("unexpected error: %s", err)
}
if len(dotfiles) != 1 {
t.Errorf("expected 1 dotfile, got %d", len(dotfiles))
}
expected := Dotfile{
TemplateText: "template text",
SlotText: "slot text",
TemplateFilepath: "/dotfiles/template.txt",
SlotFilepath: "/dotfiles/machine/slotfile.txt",
CompiledFilepath: "/home/user/somewhere/compiledfile.txt",
}
if !reflect.DeepEqual(dotfiles[0], expected) {
t.Errorf("expected %v, got %v", expected, dotfiles[0])
}
}