| 1 | package format |
| 2 | |
| 3 | import ( |
| 4 | "github.com/onsi/ginkgo/v2" |
| 5 | "github.com/onsi/gomega" |
| 6 | "github.com/onsi/gomega/format" |
| 7 | ) |
| 8 | |
| 9 | var _ = ginkgo.Describe("RenderConsole", func() { |
| 10 | format.CharactersAroundMismatchToInclude = 30 |
| 11 | renderer := ConsoleTreeRenderer{WithValues: false} |
| 12 | |
| 13 | ginkgo.It("should render the expected output based on config reflection/tags", func() { |
| 14 | actual := testRenderTree(renderer, &struct { |
| 15 | Name string `default:"notempty"` |
| 16 | Host string `url:"host"` |
| 17 | }{}) |
| 18 | |
| 19 | expected := ` |
| 20 | Host string <URL: Host> <Required> |
| 21 | Name string <Default: notempty> |
| 22 | `[1:] |
| 23 | |
| 24 | gomega.Expect(actual).To(gomega.Equal(expected)) |
| 25 | }) |
| 26 | |
| 27 | ginkgo.It(`should render enum types as "option"`, func() { |
| 28 | actual := testRenderTree(renderer, &testEnummer{}) |
| 29 | |
| 30 | expected := ` |
| 31 | Choice option <Default: Maybe> [Yes, No, Maybe] |
| 32 | `[1:] |
| 33 | |
| 34 | gomega.Expect(actual).To(gomega.Equal(expected)) |
| 35 | }) |
| 36 | |
| 37 | ginkgo.It("should render url paths in sorted order", func() { |
| 38 | actual := testRenderTree(renderer, &struct { |
| 39 | Host string `url:"host"` |
| 40 | Path1 string `url:"path1"` |
| 41 | Path3 string `url:"path3"` |
| 42 | Path2 string `url:"path2"` |
| 43 | }{}) |
| 44 | |
| 45 | expected := ` |
| 46 | Host string <URL: Host> <Required> |
| 47 | Path1 string <URL: Path> <Required> |
| 48 | Path2 string <URL: Path> <Required> |
| 49 | Path3 string <URL: Path> <Required> |
| 50 | `[1:] |
| 51 | |
| 52 | gomega.Expect(actual).To(gomega.Equal(expected)) |
| 53 | }) |
| 54 | }) |