-
Notifications
You must be signed in to change notification settings - Fork 29
/
compiler_test.go
50 lines (47 loc) · 1.08 KB
/
compiler_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
package main
import "testing"
func TestCompiledOutputPath(t *testing.T) {
tests := []struct {
pfile projectFile
want string
strategy upFileType
}{
{
projectFile{path: "app/pages/index.up", projectFilesSubdir: "app/pages"},
"index.up.go",
upFilePage,
},
{
projectFile{path: "app/pages/about.up", projectFilesSubdir: "app/pages"},
"about.up.go",
upFilePage,
},
{
projectFile{path: "app/pages/x/sub.up", projectFilesSubdir: "app/pages"},
"x__sub.up.go",
upFilePage,
},
{
projectFile{path: "testdata/foo.up", projectFilesSubdir: ""},
"testdata__foo.up.go",
upFilePage,
},
{
projectFile{path: "app/layouts/default.up", projectFilesSubdir: "app/layouts"},
"default.layout.up.go",
upFileLayout,
},
{
projectFile{path: "app/pages/$foo.up", projectFilesSubdir: "app/pages"},
"0x24foo.up.go",
upFilePage,
},
}
for _, test := range tests {
t.Run("", func(t *testing.T) {
if got := compiledOutputPath(test.pfile, test.strategy); test.want != got {
t.Errorf("want %q, got %q", test.want, got)
}
})
}
}