(t *testing.T)
| 151 | } |
| 152 | |
| 153 | func 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 | |
| 194 | func Test_newIOStreams_spinnerDisabled(t *testing.T) { |
| 195 | tests := []struct { |
nothing calls this directly
no test coverage detected