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

Function TestAliasList

pkg/cmd/alias/list/list_test.go:17–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestAliasList(t *testing.T) {
18 tests := []struct {
19 name string
20 config string
21 isTTY bool
22 wantErr bool
23 wantStdout string
24 wantStderr string
25 }{
26 {
27 name: "empty",
28 config: "",
29 isTTY: true,
30 wantErr: true,
31 wantStdout: "",
32 wantStderr: "",
33 },
34 {
35 name: "some",
36 config: heredoc.Doc(`
37 aliases:
38 co: pr checkout
39 gc: "!gh gist create \"$@\" | pbcopy"
40 `),
41 isTTY: true,
42 wantStdout: "co: pr checkout\ngc: '!gh gist create \"$@\" | pbcopy'\n",
43 wantStderr: "",
44 },
45 {
46 name: "multiline",
47 config: heredoc.Doc(`
48 aliases:
49 one: "foo\nbar\n"
50 two: |-
51 !chicken
52 coop
53 `),
54 isTTY: true,
55 wantStdout: "one: |\n foo\n bar\ntwo: |-\n !chicken\n coop\n",
56 wantStderr: "",
57 },
58 }
59 for _, tt := range tests {
60 t.Run(tt.name, func(t *testing.T) {
61 cfg := config.NewFromString(tt.config)
62
63 ios, _, stdout, stderr := iostreams.Test()
64 ios.SetStdoutTTY(tt.isTTY)
65 ios.SetStdinTTY(tt.isTTY)
66 ios.SetStderrTTY(tt.isTTY)
67
68 factory := &cmdutil.Factory{
69 IOStreams: ios,
70 Config: func() (gh.Config, error) {
71 return cfg, nil
72 },
73 }
74

Callers

nothing calls this directly

Calls 10

NewFromStringFunction · 0.92
TestFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
NewCmdListFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected