MCPcopy Create free account
hub / github.com/auth0/auth0-cli / expectTable

Function expectTable

internal/cli/cli_test.go:15–44  ·  view source on GitHub ↗

TODO(cyx): think about whether we should extract this function in the `display` package. For now duplication might be better and less premature.

(t testing.TB, got string, header []string, data [][]string)

Source from the content-addressed store, hash-verified

13// TODO(cyx): think about whether we should extract this function in the
14// `display` package. For now duplication might be better and less premature.
15func expectTable(t testing.TB, got string, header []string, data [][]string) {
16 w := &bytes.Buffer{}
17
18 tableString := &strings.Builder{}
19 table := tablewriter.NewWriter(tableString)
20 table.SetHeader(header)
21
22 table.SetAutoWrapText(false)
23 table.SetAutoFormatHeaders(true)
24 table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
25 table.SetAlignment(tablewriter.ALIGN_LEFT)
26 table.SetCenterSeparator("")
27 table.SetColumnSeparator("")
28 table.SetRowSeparator("")
29 table.SetHeaderLine(false)
30 table.SetBorder(false)
31
32 for _, v := range data {
33 table.Append(v)
34 }
35
36 table.Render()
37 fmt.Fprint(w, tableString.String())
38
39 want := w.String()
40
41 if got != want {
42 t.Fatal(cmp.Diff(want, got))
43 }
44}

Callers 2

TestActionsDeployCmdFunction · 0.85
TestAppsListCmdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected