Skip to content

Commit 9640f32

Browse files
committed
🐛 fix(docs_test.go): rename TestToTabularMarkdownFull to TestToTabularMarkdown and remove TestToTabularMarkdownWithEmptyAppPath
✨ feat(docs_test.go): add subtests to TestToTabularMarkdown to test different scenarios 🔥 chore(docs_test.go): remove unused variable and restore MarkdownTabularDocTemplate after test
1 parent d8caf8b commit 9640f32

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

docs_test.go

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,46 +23,45 @@ func TestToMarkdownFull(t *testing.T) {
2323
expectFileContent(t, "testdata/expected-doc-full.md", res)
2424
}
2525

26-
func TestToTabularMarkdownFull(t *testing.T) {
27-
// Given
26+
func TestToTabularMarkdown(t *testing.T) {
2827
app := testApp()
2928

30-
// When
31-
res, err := app.ToTabularMarkdown("app")
32-
33-
// Then
34-
expect(t, err, nil)
35-
expectFileContent(t, "testdata/expected-tabular-markdown-full.md", res)
36-
}
37-
38-
func TestToTabularMarkdownWithEmptyAppPath(t *testing.T) {
39-
// Given
40-
app := testApp()
29+
t.Run("full", func(t *testing.T) {
30+
// When
31+
res, err := app.ToTabularMarkdown("app")
4132

42-
// When
43-
res, err := app.ToTabularMarkdown("")
33+
// Then
34+
expect(t, err, nil)
35+
expectFileContent(t, "testdata/expected-tabular-markdown-full.md", res)
36+
})
4437

45-
// Then
46-
expect(t, err, nil)
47-
expectFileContent(t, "testdata/expected-tabular-markdown-full.md", res)
48-
}
38+
t.Run("with empty path", func(t *testing.T) {
39+
// When
40+
res, err := app.ToTabularMarkdown("")
4941

50-
func TestToTabularMarkdownWithCustomAppPath(t *testing.T) {
51-
// Given
52-
app := testApp()
42+
// Then
43+
expect(t, err, nil)
44+
expectFileContent(t, "testdata/expected-tabular-markdown-full.md", res)
45+
})
5346

54-
// When
55-
res, err := app.ToTabularMarkdown("/usr/local/bin")
47+
t.Run("with custom app path", func(t *testing.T) {
48+
// When
49+
res, err := app.ToTabularMarkdown("/usr/local/bin")
5650

57-
// Then
58-
expect(t, err, nil)
59-
expectFileContent(t, "testdata/expected-tabular-markdown-custom-app-path.md", res)
51+
// Then
52+
expect(t, err, nil)
53+
expectFileContent(t, "testdata/expected-tabular-markdown-custom-app-path.md", res)
54+
})
6055
}
6156

6257
func TestToTabularMarkdownFailed(t *testing.T) {
58+
tpl := MarkdownTabularDocTemplate
59+
defer func() { MarkdownTabularDocTemplate = tpl }() // restore
60+
61+
MarkdownTabularDocTemplate = "{{ .Foo }}" // invalid template
62+
6363
// Given
6464
app := testApp()
65-
MarkdownTabularDocTemplate = "{{ .Foo }}" // invalid template
6665

6766
// When
6867
res, err := app.ToTabularMarkdown("")

0 commit comments

Comments
 (0)