(t *testing.T)
| 221 | } |
| 222 | |
| 223 | func Test_refreshRun(t *testing.T) { |
| 224 | tests := []struct { |
| 225 | name string |
| 226 | opts *RefreshOptions |
| 227 | prompterStubs func(*prompter.PrompterMock) |
| 228 | cfgHosts []string |
| 229 | authOut authOut |
| 230 | oldScopes string |
| 231 | clipboard string |
| 232 | wantErr string |
| 233 | nontty bool |
| 234 | wantAuthArgs authArgs |
| 235 | }{ |
| 236 | { |
| 237 | name: "no hosts configured", |
| 238 | opts: &RefreshOptions{}, |
| 239 | wantErr: `not logged in to any hosts`, |
| 240 | }, |
| 241 | { |
| 242 | name: "hostname given but not previously authenticated with it", |
| 243 | cfgHosts: []string{ |
| 244 | "github.com", |
| 245 | "aline.cedrac", |
| 246 | }, |
| 247 | opts: &RefreshOptions{ |
| 248 | Hostname: "obed.morton", |
| 249 | }, |
| 250 | wantErr: `not logged in to obed.morton`, |
| 251 | }, |
| 252 | { |
| 253 | name: "hostname provided and is configured", |
| 254 | cfgHosts: []string{ |
| 255 | "obed.morton", |
| 256 | "github.com", |
| 257 | }, |
| 258 | opts: &RefreshOptions{ |
| 259 | Hostname: "obed.morton", |
| 260 | }, |
| 261 | wantAuthArgs: authArgs{ |
| 262 | hostname: "obed.morton", |
| 263 | scopes: []string{}, |
| 264 | secureStorage: true, |
| 265 | clipboard: true, |
| 266 | }, |
| 267 | }, |
| 268 | { |
| 269 | name: "no hostname, one host configured, clipboard enabled", |
| 270 | cfgHosts: []string{ |
| 271 | "github.com", |
| 272 | }, |
| 273 | opts: &RefreshOptions{ |
| 274 | Hostname: "", |
| 275 | Clipboard: new(true), |
| 276 | }, |
| 277 | wantAuthArgs: authArgs{ |
| 278 | hostname: "github.com", |
| 279 | scopes: []string{}, |
| 280 | secureStorage: true, |
nothing calls this directly
no test coverage detected