MCPcopy
hub / github.com/cli/cli / TestSetRun

Function TestSetRun

pkg/cmd/alias/set/set_test.go:98–310  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func TestSetRun(t *testing.T) {
99 tests := []struct {
100 name string
101 tty bool
102 opts *SetOptions
103 stdin string
104 wantExpansion string
105 wantStdout string
106 wantStderr string
107 wantErrMsg string
108 }{
109 {
110 name: "creates alias tty",
111 tty: true,
112 opts: &SetOptions{
113 Name: "foo",
114 Expansion: "bar",
115 },
116 wantExpansion: "bar",
117 wantStderr: "- Creating alias for foo: bar\n✓ Added alias foo\n",
118 },
119 {
120 name: "creates alias",
121 opts: &SetOptions{
122 Name: "foo",
123 Expansion: "bar",
124 },
125 wantExpansion: "bar",
126 },
127 {
128 name: "creates shell alias tty",
129 tty: true,
130 opts: &SetOptions{
131 Name: "igrep",
132 Expansion: "!gh issue list | grep",
133 },
134 wantExpansion: "!gh issue list | grep",
135 wantStderr: "- Creating alias for igrep: !gh issue list | grep\n✓ Added alias igrep\n",
136 },
137 {
138 name: "creates shell alias",
139 opts: &SetOptions{
140 Name: "igrep",
141 Expansion: "!gh issue list | grep",
142 },
143 wantExpansion: "!gh issue list | grep",
144 },
145 {
146 name: "creates shell alias using flag tty",
147 tty: true,
148 opts: &SetOptions{
149 Name: "igrep",
150 Expansion: "gh issue list | grep",
151 IsShell: true,
152 },
153 wantExpansion: "!gh issue list | grep",
154 wantStderr: "- Creating alias for igrep: !gh issue list | grep\n✓ Added alias igrep\n",
155 },

Callers

nothing calls this directly

Calls 14

ValidAliasNameFuncFunction · 0.92
ValidAliasExpansionFuncFunction · 0.92
TestFunction · 0.92
NewBlankConfigFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
WriteCallsMethod · 0.80
EqualMethod · 0.80
setRunFunction · 0.70
RunMethod · 0.65
AliasesMethod · 0.65

Tested by

no test coverage detected