MCPcopy
hub / github.com/cli/cli / Test_newIOStreams_prompt

Function Test_newIOStreams_prompt

internal/ghcmd/cmd_test.go:153–192  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

151}
152
153func Test_newIOStreams_prompt(t *testing.T) {
154 tests := []struct {
155 name string
156 config gh.Config
157 promptDisabled bool
158 env map[string]string
159 }{
160 {
161 name: "default config",
162 promptDisabled: false,
163 },
164 {
165 name: "config with prompt disabled",
166 config: disablePromptConfig(),
167 promptDisabled: true,
168 },
169 {
170 name: "prompt disabled via GH_PROMPT_DISABLED env var",
171 env: map[string]string{"GH_PROMPT_DISABLED": "1"},
172 promptDisabled: true,
173 },
174 }
175 for _, tt := range tests {
176 t.Run(tt.name, func(t *testing.T) {
177 if tt.env != nil {
178 for k, v := range tt.env {
179 t.Setenv(k, v)
180 }
181 }
182 var cfg gh.Config
183 if tt.config != nil {
184 cfg = tt.config
185 } else {
186 cfg = config.NewBlankConfig()
187 }
188 io := newIOStreams(cfg)
189 assert.Equal(t, tt.promptDisabled, io.GetNeverPrompt())
190 })
191 }
192}
193
194func Test_newIOStreams_spinnerDisabled(t *testing.T) {
195 tests := []struct {

Callers

nothing calls this directly

Calls 6

NewBlankConfigFunction · 0.92
disablePromptConfigFunction · 0.85
newIOStreamsFunction · 0.85
EqualMethod · 0.80
GetNeverPromptMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected