-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain_test.go
84 lines (75 loc) · 1.6 KB
/
main_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
package main
import (
"fmt"
"testing"
"github.com/jarvanstack/gitbook-summary/config"
"github.com/jarvanstack/gitbook-summary/matcher"
)
// func TestMain1(m *testing.M) {
// config.Init(config.WithConfigPath("docs/gitbook-summary.yaml"))
// m.Run()
// os.Exit(0)
// }
func TestMainFunc(t *testing.T) {
config.Init(config.WithConfigPath("/Users/hcm-b0487/workspace/work2/study1/doc2/docs/gitbook-summary.yaml"), config.WithRootDir("/Users/hcm-b0487/workspace/work2/study1/doc2/docs"))
Summary(config.Global.RootDir, config.Global)
}
func Test_Scan(t *testing.T) {
root, err := ScanDir(".")
if err != nil {
t.Error(err)
return
}
printTree(root, "")
}
func TestScanAndSort(t *testing.T) {
// config.Init("gitbook-summary.yaml")
IgnoreMatcher = matcher.NewRegexMatcher([]string{"git"})
root, err := ScanDir("data")
if err != nil {
t.Error(err)
return
}
// 获取 summary 内容
summary := GenerateSummary(root)
fmt.Println(summary)
}
func TestFileNameToTitle(t *testing.T) {
type args struct {
fileName string
}
tests := []struct {
name string
args args
want string
}{
{
args: args{
fileName: "test.md",
},
want: "Test",
},
{
args: args{
fileName: "09234a-test.md",
},
want: "Test",
},
{
args: args{
fileName: "09234a-test Test2.md",
},
want: "Test Test2",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := FileNameToTitle(tt.args.fileName); got != tt.want {
t.Errorf("FileNameToTitle() = %v, want %v", got, tt.want)
}
})
}
}
func TestSummary(t *testing.T) {
Summary("./docs", config.Global)
}