-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
177 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package format | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
gformat "github.com/onsi/gomega/format" | ||
) | ||
|
||
var _ = Describe("RenderConsole", func() { | ||
gformat.CharactersAroundMismatchToInclude = 30 | ||
renderer := ConsoleTreeRenderer{WithValues: false} | ||
|
||
It("should render the expected output based on config reflection/tags", func() { | ||
actual := testRenderTee(renderer, &struct { | ||
Name string `default:"notempty"` | ||
Host string `url:"host"` | ||
}{}) | ||
|
||
expected := ` | ||
Host string <URL: Host> <Required> | ||
Name string <Default: notempty> | ||
`[1:] | ||
println() | ||
println(actual) | ||
|
||
Expect(actual).To(Equal(expected)) | ||
}) | ||
|
||
It("should render url paths in sorted order", func() { | ||
actual := testRenderTee(renderer, &struct { | ||
Host string `url:"host"` | ||
Path1 string `url:"path1"` | ||
Path3 string `url:"path3"` | ||
Path2 string `url:"path2"` | ||
}{}) | ||
|
||
expected := ` | ||
Host string <URL: Host> <Required> | ||
Path1 string <URL: Path> <Required> | ||
Path2 string <URL: Path> <Required> | ||
Path3 string <URL: Path> <Required> | ||
`[1:] | ||
|
||
println() | ||
println(actual) | ||
|
||
Expect(actual).To(Equal(expected)) | ||
}) | ||
}) | ||
|
||
/* | ||
* __TestEnum__ | ||
Default: `+"`None`"+` | ||
Possible values: `+"`None`, `Foo`, `Bar`"+` | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package format | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
gformat "github.com/onsi/gomega/format" | ||
) | ||
|
||
var _ = Describe("RenderMarkdown", func() { | ||
gformat.CharactersAroundMismatchToInclude = 30 | ||
|
||
It("should render the expected output based on config reflection/tags", func() { | ||
actual := testRenderTee(MarkdownTreeRenderer{HeaderPrefix: `### `}, &struct { | ||
Name string `default:"notempty"` | ||
Host string `url:"host"` | ||
}{}) | ||
|
||
expected := ` | ||
### URL Fields | ||
* __Host__ (**Required**) | ||
URL part: <code class="service-url">mock://<strong>host</strong>/</code> | ||
### Query/Param Props | ||
* __Name__ | ||
Default: `[1:] + "`notempty`" + ` | ||
` | ||
|
||
Expect(actual).To(Equal(expected)) | ||
}) | ||
|
||
It("should render url paths in sorted order", func() { | ||
actual := testRenderTee(MarkdownTreeRenderer{HeaderPrefix: `### `}, &struct { | ||
Host string `url:"host"` | ||
Path1 string `url:"path1"` | ||
Path3 string `url:"path3"` | ||
Path2 string `url:"path2"` | ||
}{}) | ||
|
||
expected := ` | ||
### URL Fields | ||
* __Host__ (**Required**) | ||
URL part: <code class="service-url">mock://<strong>host</strong>/path1/path2/path3</code> | ||
* __Path1__ (**Required**) | ||
URL part: <code class="service-url">mock://host/<strong>path1</strong>/path2/path3</code> | ||
* __Path2__ (**Required**) | ||
URL part: <code class="service-url">mock://host/path1/<strong>path2</strong>/path3</code> | ||
* __Path3__ (**Required**) | ||
URL part: <code class="service-url">mock://host/path1/path2/<strong>path3</strong></code> | ||
### Query/Param Props | ||
`[1:] // Remove initial newline | ||
|
||
Expect(actual).To(Equal(expected)) | ||
}) | ||
}) | ||
|
||
/* | ||
* __TestEnum__ | ||
Default: `+"`None`"+` | ||
Possible values: `+"`None`, `Foo`, `Bar`"+` | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package format | ||
|
||
// Renderer renders a supplied node tree to a string | ||
type Renderer interface { | ||
// RenderTree renders a ContainerNode tree into a ansi-colored console string | ||
RenderTree(root *ContainerNode, scheme string) string | ||
} | ||
|
||
func testRenderTee(r Renderer, v interface{}) string { | ||
return r.RenderTree(getRootNode(v), "mock") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters