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

Function Test_newIOStreams_prompt

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

Source from the content-addressed store, hash-verified

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