-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblawg_test.go
55 lines (44 loc) · 1.75 KB
/
blawg_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
package blawg
import (
"io/ioutil"
"testing"
)
var testSiteDirectory = "test-site-directory"
var testTemplateDirectory = "example/templates"
var testExtrasDirectory = "example/extras"
var testPostDirectory = "example/posts"
var testPagesDirectory = "example/pages"
func TestMakeBlog(t *testing.T) {
assert := NewAssertions(t)
err := MakeBlawg(
testPostDirectory,
testPagesDirectory,
testTemplateDirectory,
testExtrasDirectory,
testSiteDirectory,
)
assert.NotError(err)
assert.DirectoryExists(testSiteDirectory)
assert.DirectoryExists(testSiteDirectory + "/posts")
assert.DirectoryExists(testSiteDirectory + "/css")
assert.DirectoryExists(testSiteDirectory + "/pages")
assert.DirectoryExists(testSiteDirectory + "/feeds")
assert.FileExists(testSiteDirectory + "/feeds/feed.rss")
assert.FileExists(testSiteDirectory + "/index.html")
file, err := ioutil.ReadFile(testSiteDirectory + "/index.html")
post := string(file)
assert.StringContains(post, "<h1>post two</h1>")
assert.FileExists(testSiteDirectory + "/public.txt")
assert.FileExists(testSiteDirectory + "/css/styles.css")
assert.FileExists(testSiteDirectory + "/posts/index.html")
assert.FileExists(testSiteDirectory + "/posts/2016/3/28/post-one/index.html")
assert.FileExists(testSiteDirectory + "/posts/2017/10/21/post-two/index.html")
assert.FileExists(testSiteDirectory + "/posts/1989/1/1/100--escape/index.html")
assert.FileDoesntExist(testSiteDirectory + "/posts/1901/1/1/not-to-be-published/index.html")
file, err = ioutil.ReadFile(testSiteDirectory + "/posts/2017/10/21/post-two/index.html")
assert.NotError(err)
post = string(file)
assert.StringContainsInOrder(post, "post two", "post one")
assert.FileExists(testSiteDirectory + "/pages/about/index.html")
// tearDownTestSite(t)
}