This repository has been archived by the owner on Apr 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathutil_test.go
114 lines (97 loc) · 2.74 KB
/
util_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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package main
import (
"testing"
)
func TestAppendExt(t *testing.T) {
if ext := appendExt("/test.html", ".html"); ext != "/test.html" {
t.Errorf("Expected appended extension [/test.html] got [%s]", ext)
}
if ext := appendExt("/test", ".html"); ext != "/test.html" {
t.Errorf("Expected appended extension [/test.html] got [%s]", ext)
}
}
func TestHasMatter(t *testing.T) {
// TODO
}
func TestIsHiddenOrTemp(t *testing.T) {
tests := map[string]bool {
".tmp" : true,
"tmp~" : true,
"tmp" : false,
".git" : true }
for key, val := range tests {
if result := isHiddenOrTemp(key); result != val {
t.Errorf("Expected IsHiddenOrTemp value of [%v] got [%v] for file [%s]", val, result, key)
}
}
}
func TestIsTemplate(t *testing.T) {
tests := map[string]bool {
"_layouts/page.html" : true,
"_includes/page.html" : true,
"_includes/page.html~" : false,
"static/js/script.js" : false,
"index.html" : false }
for key, val := range tests {
if result := isTemplate(key); result != val {
t.Errorf("Expected IsTemplate value of [%v] got [%v] for file [%s]", val, result, key)
}
}
}
func TestIsHtml(t *testing.T) {
tests := map[string]bool {
"page.html" : true,
"page.xml" : true,
"page.html~" : false,
"page.rss" : true,
"page.atom" : true }
for key, val := range tests {
if result := isHtml(key); result != val {
t.Errorf("Expected IsHtml value of [%v] got [%v] for file [%s]", val, result, key)
}
}
}
func TestIsMarkdown(t *testing.T) {
tests := map[string]bool {
"page.md" : true,
"page.markdown" : true,
"page.md~" : false }
for key, val := range tests {
if result := isMarkdown(key); result != val {
t.Errorf("Expected IsMarkdown value of [%v] got [%v] for file [%s]", val, result, key)
}
}
}
func TestIsPage(t *testing.T) {
// TODO
}
func TestIsPost(t *testing.T) {
// TODO
}
func TestIsStatic(t *testing.T) {
tests := map[string]bool {
"_site" : false,
"_site/index.html" : false,
"img/logo.png" : true }
for key, val := range tests {
if result := isStatic(key); result != val {
t.Errorf("Expected isStatic value of [%v] got [%v] for file [%s]", val, result, key)
}
}
}
func TestRemoveExt(t *testing.T) {
if ext := removeExt("/test"); ext != "/test" {
t.Errorf("Expected removed extension [/test] got [%s]", ext)
}
if ext := removeExt("/test.html"); ext != "/test" {
t.Errorf("Expected removed extension [/test] got [%s]", ext)
}
}
func TestReplaceExt(t *testing.T) {
if ext := replaceExt("/test", ".html"); ext != "/test.html" {
t.Errorf("Expected replaced extension [/test.html] got [%s]", ext)
}
if ext := replaceExt("/test.markdown", ".html"); ext != "/test.html" {
t.Errorf("Expected replaced extension [/test.html] got [%s]", ext)
}
}