Skip to content

Commit

Permalink
🐛 fix(docs_test.go): rename TestToTabularMarkdownFull to TestToTabula…
Browse files Browse the repository at this point in the history
…rMarkdown 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
  • Loading branch information
tarampampam committed May 1, 2023
1 parent d8caf8b commit 9640f32
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,45 @@ func TestToMarkdownFull(t *testing.T) {
expectFileContent(t, "testdata/expected-doc-full.md", res)
}

func TestToTabularMarkdownFull(t *testing.T) {
// Given
func TestToTabularMarkdown(t *testing.T) {
app := testApp()

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

// Then
expect(t, err, nil)
expectFileContent(t, "testdata/expected-tabular-markdown-full.md", res)
}

func TestToTabularMarkdownWithEmptyAppPath(t *testing.T) {
// Given
app := testApp()
t.Run("full", func(t *testing.T) {
// When
res, err := app.ToTabularMarkdown("app")

// When
res, err := app.ToTabularMarkdown("")
// Then
expect(t, err, nil)
expectFileContent(t, "testdata/expected-tabular-markdown-full.md", res)
})

// Then
expect(t, err, nil)
expectFileContent(t, "testdata/expected-tabular-markdown-full.md", res)
}
t.Run("with empty path", func(t *testing.T) {
// When
res, err := app.ToTabularMarkdown("")

func TestToTabularMarkdownWithCustomAppPath(t *testing.T) {
// Given
app := testApp()
// Then
expect(t, err, nil)
expectFileContent(t, "testdata/expected-tabular-markdown-full.md", res)
})

// When
res, err := app.ToTabularMarkdown("/usr/local/bin")
t.Run("with custom app path", func(t *testing.T) {
// When
res, err := app.ToTabularMarkdown("/usr/local/bin")

// Then
expect(t, err, nil)
expectFileContent(t, "testdata/expected-tabular-markdown-custom-app-path.md", res)
// Then
expect(t, err, nil)
expectFileContent(t, "testdata/expected-tabular-markdown-custom-app-path.md", res)
})
}

func TestToTabularMarkdownFailed(t *testing.T) {
tpl := MarkdownTabularDocTemplate
defer func() { MarkdownTabularDocTemplate = tpl }() // restore

MarkdownTabularDocTemplate = "{{ .Foo }}" // invalid template

// Given
app := testApp()
MarkdownTabularDocTemplate = "{{ .Foo }}" // invalid template

// When
res, err := app.ToTabularMarkdown("")
Expand Down

0 comments on commit 9640f32

Please sign in to comment.