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