(t *testing.T)
| 251 | } |
| 252 | |
| 253 | func Test_refreshRun(t *testing.T) { |
| 254 | tests := []struct { |
| 255 | name string |
| 256 | opts *RefreshOptions |
| 257 | prompterStubs func(*prompter.PrompterMock) |
| 258 | cfgHosts []string |
| 259 | cfgRefreshable bool |
| 260 | cfgRefreshableExpired bool |
| 261 | refreshSkipped bool |
| 262 | refresher *ghmock.TokenRefresherMock |
| 263 | authOut authOut |
| 264 | oldScopes string |
| 265 | clipboard string |
| 266 | expiringCredentialsCfg string |
| 267 | wantErr string |
| 268 | nontty bool |
| 269 | wantAuthArgs authArgs |
| 270 | wantStoredToken string |
| 271 | wantStoredRefreshToken string |
| 272 | wantStderrContains string |
| 273 | wantStderrOmits string |
| 274 | }{ |
| 275 | { |
| 276 | name: "no hosts configured", |
| 277 | opts: &RefreshOptions{}, |
| 278 | wantErr: `not logged in to any hosts`, |
| 279 | }, |
| 280 | { |
| 281 | name: "hostname given but not previously authenticated with it", |
| 282 | cfgHosts: []string{ |
| 283 | "github.com", |
| 284 | "aline.cedrac", |
| 285 | }, |
| 286 | opts: &RefreshOptions{ |
| 287 | Hostname: "obed.morton", |
| 288 | }, |
| 289 | wantErr: `not logged in to obed.morton`, |
| 290 | }, |
| 291 | { |
| 292 | name: "hostname provided and is configured", |
| 293 | cfgHosts: []string{ |
| 294 | "obed.morton", |
| 295 | "github.com", |
| 296 | }, |
| 297 | opts: &RefreshOptions{ |
| 298 | Hostname: "obed.morton", |
| 299 | }, |
| 300 | wantAuthArgs: authArgs{ |
| 301 | hostname: "obed.morton", |
| 302 | scopes: []string{}, |
| 303 | secureStorage: true, |
| 304 | clipboard: true, |
| 305 | }, |
| 306 | }, |
| 307 | { |
| 308 | name: "no hostname, one host configured, clipboard enabled", |
| 309 | cfgHosts: []string{ |
| 310 | "github.com", |
nothing calls this directly
no test coverage detected