MCPcopy Create free account
hub / github.com/cli/cli / TestDedent

Function TestDedent

pkg/cmd/root/help_test.go:22–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20)
21
22func TestDedent(t *testing.T) {
23 type c struct {
24 input string
25 expected string
26 }
27
28 cases := []c{
29 {
30 input: " --help Show help for command\n --version Show gh version\n",
31 expected: "--help Show help for command\n--version Show gh version\n",
32 },
33 {
34 input: " --help Show help for command\n -R, --repo OWNER/REPO Select another repository using the OWNER/REPO format\n",
35 expected: " --help Show help for command\n-R, --repo OWNER/REPO Select another repository using the OWNER/REPO format\n",
36 },
37 {
38 input: " line 1\n\n line 2\n line 3",
39 expected: " line 1\n\n line 2\nline 3",
40 },
41 {
42 input: " line 1\n line 2\n line 3\n\n",
43 expected: "line 1\nline 2\nline 3\n\n",
44 },
45 {
46 input: "\n\n\n\n\n\n",
47 expected: "\n\n\n\n\n\n",
48 },
49 {
50 input: "",
51 expected: "",
52 },
53 }
54
55 for _, tt := range cases {
56 got := dedent(tt.input)
57 if got != tt.expected {
58 t.Errorf("expected: %q, got: %q", tt.expected, got)
59 }
60 }
61}
62
63// Since our online docs website renders pages by using the kramdown (a superset
64// of Markdown) engine, we have to check against some known quirks of the

Callers

nothing calls this directly

Calls 2

dedentFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected