-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_test.go
More file actions
42 lines (36 loc) · 1.22 KB
/
parse_test.go
File metadata and controls
42 lines (36 loc) · 1.22 KB
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
package tpl
import (
"testing"
)
func TestParseDir(t *testing.T) {
files, err := parseDir("testdata/", ".html")
ok(t, err)
equals(t, 6, len(files))
}
func TestParseDirNotFound(t *testing.T) {
files, err := parseDir("nonexists", ".html")
assert(t, err != nil, "err is nil")
equals(t, 0, len(files))
}
func TestParseFile(t *testing.T) {
file, err := parseFile("testdata/", "testdata/standalone/standalone.html")
ok(t, err)
equals(t, "testdata/standalone/standalone.html", file.abspath)
equals(t, "standalone/standalone.html", file.path)
assert(t, file.parent == nil, "file.parent is not nil")
assert(t, len(file.content) > 0, "file.content is zero len")
}
func TestParseFileExtended(t *testing.T) {
file, err := parseFile("testdata/", "testdata/middle.html")
ok(t, err)
equals(t, "testdata/middle.html", file.abspath)
equals(t, "middle.html", file.path)
assert(t, file.parent != nil, "file.parent is nil")
assert(t, *file.parent == "top.html", "file.parent is not equal top.html")
assert(t, len(file.content) > 0, "file.content is zero len")
}
func TestParseFileNotFound(t *testing.T) {
file, err := parseFile("testdata/", "testdata/foo.html")
assert(t, err != nil, "err is nil")
assert(t, file == nil, "file is not nil")
}