Commit 1e49feca authored by Ma_124's avatar Ma_124

improved testing

parent 5aea0980
Pipeline #53329045 passed with stages
in 2 minutes and 16 seconds
......@@ -92,7 +92,11 @@ func NewCtx(apis *ApisCfg) *Ctx {
}
func NewDebugReqsApisCfg() *ApisCfg {
return &ApisCfg{true, &ApiCfg{"", 6000}}
return &ApisCfg{false, &ApiCfg{"", 6000}}
}
func NewDebugCfg() *ApisCfg {
return &ApisCfg{false, &ApiCfg{}}
}
func NewDebugCtx() *Ctx {
......
......@@ -40,7 +40,7 @@ d e f
ghi
`[1:]
Compile(strings.NewReader(in), len(in), &strings.Builder{}, IFFTabSep(NameUrlDescTabSepPattern), OFFTabSep(NameUrlDescTabSepPattern), nil)
Compile(strings.NewReader(in), len(in), &strings.Builder{}, IFFTabSep(NameUrlDescTabSepPattern), OFFTabSep(NameUrlDescTabSepPattern), NewDebugCfg())
}
func TestCompile_MarkdownTabSep(t *testing.T) {
......@@ -60,7 +60,8 @@ A curated list of awesome curated lists of many topics.
For contributing, [open an issue](https://github.com/emijrp/awesome-awesome/issues) and/or a [pull request](https://github.com/emijrp/awesome-awesome/pulls). Above there are some ideas for missing lists, be bold!
`[1:]
Compile(strings.NewReader(in), len(in), out, IFFMarkdown(" - "), OFFTabSep(NameUrlDescTabSepPattern), &ApisCfg{&ApiCfg{}})
Compile(strings.NewReader(in), len(in), out, IFFMarkdown(" - "), OFFTabSep(NameUrlDescTabSepPattern), NewDebugCfg())
NewDebugReqsApisCfg()
assert.Equal(t, awesomeAwesomeShortOut, out.String())
}
......@@ -77,7 +78,7 @@ func TestCompileFile_TmpFile(t *testing.T) {
_ = f.Close()
buf := &strings.Builder{}
CompileFile(f.Name(), buf, IFFTabSep(NameUrlDescTabSepPattern), OFFTabSep(NameUrlDescTabSepPattern), &ApisCfg{&ApiCfg{}})
CompileFile(f.Name(), buf, IFFTabSep(NameUrlDescTabSepPattern), OFFTabSep(NameUrlDescTabSepPattern), NewDebugCfg())
assert.Equal(t, buf.String(), awesomeAwesomeShortOut)
}
......@@ -112,7 +113,7 @@ func TestCompileFile_NoReadPermFile(t *testing.T) {
panic(err)
}
CompileFile(fname, &strings.Builder{}, IFFTabSep(NameUrlDescTabSepPattern), OFFTabSep(NameUrlDescTabSepPattern), nil)
CompileFile(fname, &strings.Builder{}, IFFTabSep(NameUrlDescTabSepPattern), OFFTabSep(NameUrlDescTabSepPattern), NewDebugCfg())
}
type testCompileFileReadErr struct{}
......@@ -128,5 +129,5 @@ func TestCompileFile_ReadErr(t *testing.T) {
assert.Equal(t, r, errors.New("error by mocked reader"))
}()
Compile(&testCompileFileReadErr{}, 0, &strings.Builder{}, IFFTabSep(NameUrlDescTabSepPattern), OFFTabSep(NameUrlDescTabSepPattern), nil)
Compile(&testCompileFileReadErr{}, 0, &strings.Builder{}, IFFTabSep(NameUrlDescTabSepPattern), OFFTabSep(NameUrlDescTabSepPattern), NewDebugCfg())
}
......@@ -29,7 +29,7 @@ awesome-sysadmin https://github.com/kahun/awesome-sysadmin B
func TestCompile_TabSepTabSep(t *testing.T) {
out := &strings.Builder{}
Compile(strings.NewReader(awesomeAwesomeShortInp), len(awesomeAwesomeShortInp), out, IFFTabSep(NameUrlDescTabSepPattern), OFFTabSep(NameUrlDescTabSepPattern), &ApisCfg{&ApiCfg{}})
Compile(strings.NewReader(awesomeAwesomeShortInp), len(awesomeAwesomeShortInp), out, IFFTabSep(NameUrlDescTabSepPattern), OFFTabSep(NameUrlDescTabSepPattern), NewDebugCfg())
assert.Equal(t, `
'# Awesome
......@@ -51,7 +51,7 @@ awesome-sysadmin https://github.com/kahun/awesome-sysadmin Backups, configuratio
func TestCompile_TabSepSimpleMarkdown(t *testing.T) {
out := &strings.Builder{}
Compile(strings.NewReader(awesomeAwesomeShortInp), len(awesomeAwesomeShortInp), out, IFFTabSep(NameUrlDescTabSepPattern), OFFSimpleMarkdown(), &ApisCfg{&ApiCfg{}})
Compile(strings.NewReader(awesomeAwesomeShortInp), len(awesomeAwesomeShortInp), out, IFFTabSep(NameUrlDescTabSepPattern), OFFSimpleMarkdown(), NewDebugCfg())
assert.Equal(t, `
# Awesome Awesome
......@@ -75,7 +75,7 @@ For contributing, [open an issue](https://github.com/emijrp/awesome-awesome/issu
func TestCompile_TabSepMarkdown(t *testing.T) {
out := &strings.Builder{}
Compile(strings.NewReader(awesomeAwesomeShortInp), len(awesomeAwesomeShortInp), out, IFFTabSep(NameUrlDescTabSepPattern), OFFMarkdown(), &ApisCfg{&ApiCfg{}})
Compile(strings.NewReader(awesomeAwesomeShortInp), len(awesomeAwesomeShortInp), out, IFFTabSep(NameUrlDescTabSepPattern), OFFMarkdown(), NewDebugCfg())
assert.Equal(t, `
# Awesome Awesome
......@@ -99,7 +99,7 @@ For contributing, [open an issue](https://github.com/emijrp/awesome-awesome/issu
func TestCompile_TabSepSimpleMarkdownHtml(t *testing.T) {
out := &strings.Builder{}
Compile(strings.NewReader(awesomeAwesomeShortInp), len(awesomeAwesomeShortInp), out, IFFTabSep(NameUrlDescTabSepPattern), OFFSimpleMarkdownHtml(), &ApisCfg{&ApiCfg{}})
Compile(strings.NewReader(awesomeAwesomeShortInp), len(awesomeAwesomeShortInp), out, IFFTabSep(NameUrlDescTabSepPattern), OFFSimpleMarkdownHtml(), NewDebugCfg())
assert.Equal(t, string(blackfriday.Run([]byte(`
# Awesome Awesome
......@@ -123,7 +123,7 @@ For contributing, [open an issue](https://github.com/emijrp/awesome-awesome/issu
func TestCompile_TabSepMarkdownHtml(t *testing.T) {
out := &strings.Builder{}
Compile(strings.NewReader(awesomeAwesomeShortInp), len(awesomeAwesomeShortInp), out, IFFTabSep(NameUrlDescTabSepPattern), OFFMarkdownHtml(), &ApisCfg{&ApiCfg{}})
Compile(strings.NewReader(awesomeAwesomeShortInp), len(awesomeAwesomeShortInp), out, IFFTabSep(NameUrlDescTabSepPattern), OFFMarkdownHtml(), NewDebugCfg())
assert.Equal(t, string(blackfriday.Run([]byte(`
# Awesome Awesome
......@@ -156,7 +156,7 @@ g h i
j k l
"</main>`[1:]
Compile(strings.NewReader(in), len(in), out, IFFTabSep(NameUrlDescTabSepPattern), OFFHtml(), &ApisCfg{&ApiCfg{}})
Compile(strings.NewReader(in), len(in), out, IFFTabSep(NameUrlDescTabSepPattern), OFFHtml(), NewDebugCfg())
assert.Equal(t, `
<main>
......
......@@ -91,7 +91,7 @@ func TestFetchMeta(t *testing.T) {
}
for i, test := range tests {
m := FetchMeta(test.URL, &Ctx{ApisCfg: &ApisCfg{&ApiCfg{"TOK", 6000}}})
m := FetchMeta(test.URL, &Ctx{ApisCfg: &ApisCfg{false, &ApiCfg{"TOK", 6000}}})
if test.Provider == "gh" {
if m.Stars() != "1234" || m.Forks() != "56" || m.Issues() != "7" || m.LastCommit() != "2006-01-02" {
t.Fatalf("%v: Unexpected output for GitHub API Response. (%+v)\n", i, m)
......
......@@ -134,7 +134,7 @@ func testTestOFF(t *testing.T, name string, off *OutputFileFormat, fail bool, in
panic(r)
}
}()
Compile(strings.NewReader(in), len(in), ioutil.Discard, IFFTabSep(NameUrlDescTabSepPattern), off, &ApisCfg{&ApiCfg{}})
Compile(strings.NewReader(in), len(in), ioutil.Discard, IFFTabSep(NameUrlDescTabSepPattern), off, NewDebugCfg())
}
func TestNoopLiteral(t *testing.T) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment