-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbook_test.go
98 lines (72 loc) · 2.01 KB
/
book_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
package gbook
import (
"io/ioutil"
"os"
"testing"
)
func Test_Info_Compile(t *testing.T) {
inputFolder, _ := ioutil.TempDir(os.TempDir(), "input*")
outputFolder, _ := ioutil.TempDir(os.TempDir(), "output*")
defer os.RemoveAll(inputFolder)
defer os.RemoveAll(outputFolder)
content := `# Hello World
Lorem ipsum dolor sit amet, consectetur adipiscing elit`
ioutil.WriteFile(inputFolder+"/README.md", []byte(content), 0644)
book := New()
book.SourceFolderPath = inputFolder
book.OutputFolderPath = outputFolder
book.CompileCheckFile = true
book.InitOutputFolder()
book.Compile()
data, err := ioutil.ReadFile(outputFolder + "/README.compiled.xml")
if err != nil {
t.Fatal(err)
}
t.Logf("%s", data)
}
func Test_Info_CompileTable(t *testing.T) {
inputFolder, _ := ioutil.TempDir(os.TempDir(), "input*")
outputFolder, _ := ioutil.TempDir(os.TempDir(), "output*")
defer os.RemoveAll(inputFolder)
defer os.RemoveAll(outputFolder)
content := `# Hello World
|Name | Age |
|--------|------|
|Bob | 27 |
|Alice | 23|`
ioutil.WriteFile(inputFolder+"/README.md", []byte(content), 0644)
book := New()
book.SourceFolderPath = inputFolder
book.OutputFolderPath = outputFolder
book.CompileCheckFile = true
book.InitOutputFolder()
book.Compile()
data, err := ioutil.ReadFile(outputFolder + "/README.compiled.xml")
if err != nil {
t.Fatal(err)
}
t.Logf("%s", data)
}
func Test_Info_CompileList(t *testing.T) {
inputFolder, _ := ioutil.TempDir(os.TempDir(), "input*")
outputFolder, _ := ioutil.TempDir(os.TempDir(), "output*")
defer os.RemoveAll(inputFolder)
defer os.RemoveAll(outputFolder)
content := `# Hello World
* Bob
* Alice
1. One
2. Two`
ioutil.WriteFile(inputFolder+"/README.md", []byte(content), 0644)
book := New()
book.SourceFolderPath = inputFolder
book.OutputFolderPath = outputFolder
book.CompileCheckFile = true
book.InitOutputFolder()
book.Compile()
data, err := ioutil.ReadFile(outputFolder + "/README.compiled.xml")
if err != nil {
t.Fatal(err)
}
t.Logf("%s", data)
}