(t *testing.T)
| 410 | } |
| 411 | |
| 412 | func Test_mightBeGHESUser(t *testing.T) { |
| 413 | tests := []struct { |
| 414 | name string |
| 415 | env map[string]string |
| 416 | config gh.Config |
| 417 | want bool |
| 418 | }{ |
| 419 | { |
| 420 | name: "GH_ENTERPRISE_TOKEN set", |
| 421 | env: map[string]string{"GH_ENTERPRISE_TOKEN": "some-token"}, |
| 422 | config: config.NewBlankConfig(), |
| 423 | want: true, |
| 424 | }, |
| 425 | { |
| 426 | name: "GITHUB_ENTERPRISE_TOKEN set", |
| 427 | env: map[string]string{"GITHUB_ENTERPRISE_TOKEN": "some-token"}, |
| 428 | config: config.NewBlankConfig(), |
| 429 | want: true, |
| 430 | }, |
| 431 | { |
| 432 | name: "no env vars, config has enterprise host", |
| 433 | config: config.NewFromString("hosts:\n ghes.example.com:\n oauth_token: abc123\n"), |
| 434 | want: true, |
| 435 | }, |
| 436 | { |
| 437 | name: "no env vars, config has only github.com", |
| 438 | config: config.NewFromString("hosts:\n github.com:\n oauth_token: abc123\n"), |
| 439 | want: false, |
| 440 | }, |
| 441 | { |
| 442 | name: "no env vars, config has no hosts", |
| 443 | config: config.NewBlankConfig(), |
| 444 | want: false, |
| 445 | }, |
| 446 | { |
| 447 | name: "no env vars, config has github.com and enterprise host", |
| 448 | config: config.NewFromString("hosts:\n github.com:\n oauth_token: abc123\n ghes.example.com:\n oauth_token: def456\n"), |
| 449 | want: true, |
| 450 | }, |
| 451 | { |
| 452 | name: "no env vars, config has tenancy host", |
| 453 | config: config.NewFromString("hosts:\n my-company.ghe.com:\n oauth_token: abc123\n"), |
| 454 | want: false, |
| 455 | }, |
| 456 | { |
| 457 | name: "GH_HOST set to enterprise host", |
| 458 | env: map[string]string{"GH_HOST": "ghes.example.com"}, |
| 459 | config: config.NewBlankConfig(), |
| 460 | want: true, |
| 461 | }, |
| 462 | { |
| 463 | name: "GH_HOST set to github.com", |
| 464 | env: map[string]string{"GH_HOST": "github.com"}, |
| 465 | config: config.NewBlankConfig(), |
| 466 | want: false, |
| 467 | }, |
| 468 | { |
| 469 | name: "GH_HOST set to tenancy host", |
nothing calls this directly
no test coverage detected