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

Function Test_newIOStreams_prompt

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

Source from the content-addressed store, hash-verified

235}
236
237func Test_newIOStreams_prompt(t *testing.T) {
238 tests := []struct {
239 name string
240 config gh.Config
241 promptDisabled bool
242 env map[string]string
243 }{
244 {
245 name: "default config",
246 promptDisabled: false,
247 },
248 {
249 name: "config with prompt disabled",
250 config: disablePromptConfig(),
251 promptDisabled: true,
252 },
253 {
254 name: "prompt disabled via GH_PROMPT_DISABLED env var",
255 env: map[string]string{"GH_PROMPT_DISABLED": "1"},
256 promptDisabled: true,
257 },
258 }
259 for _, tt := range tests {
260 t.Run(tt.name, func(t *testing.T) {
261 if tt.env != nil {
262 for k, v := range tt.env {
263 t.Setenv(k, v)
264 }
265 }
266 var cfg gh.Config
267 if tt.config != nil {
268 cfg = tt.config
269 } else {
270 cfg = config.NewMockConfig()
271 }
272 io := newIOStreams(cfg, "")
273 assert.Equal(t, tt.promptDisabled, io.GetNeverPrompt())
274 })
275 }
276}
277
278func Test_newIOStreams_spinnerDisabled(t *testing.T) {
279 tests := []struct {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected