MCPcopy Index your code
hub / github.com/cli/cli / TestDedent

Function TestDedent

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

Source from the content-addressed store, hash-verified

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