(t *testing.T)
| 524 | } |
| 525 | |
| 526 | func Test_mightBeGHESUser(t *testing.T) { |
| 527 | tests := []struct { |
| 528 | name string |
| 529 | env map[string]string |
| 530 | cfgString string |
| 531 | want bool |
| 532 | }{ |
| 533 | { |
| 534 | name: "GH_ENTERPRISE_TOKEN set", |
| 535 | env: map[string]string{"GH_ENTERPRISE_TOKEN": "some-token"}, |
| 536 | want: true, |
| 537 | }, |
| 538 | { |
| 539 | name: "GITHUB_ENTERPRISE_TOKEN set", |
| 540 | env: map[string]string{"GITHUB_ENTERPRISE_TOKEN": "some-token"}, |
| 541 | want: true, |
| 542 | }, |
| 543 | { |
| 544 | name: "no env vars, config has enterprise host", |
| 545 | cfgString: "hosts:\n ghes.example.com:\n oauth_token: abc123\n", |
| 546 | want: true, |
| 547 | }, |
| 548 | { |
| 549 | name: "no env vars, config has only github.com", |
| 550 | cfgString: "hosts:\n github.com:\n oauth_token: abc123\n", |
| 551 | want: false, |
| 552 | }, |
| 553 | { |
| 554 | name: "no env vars, config has no hosts", |
| 555 | want: false, |
| 556 | }, |
| 557 | { |
| 558 | name: "no env vars, config has github.com and enterprise host", |
| 559 | cfgString: "hosts:\n github.com:\n oauth_token: abc123\n ghes.example.com:\n oauth_token: def456\n", |
| 560 | want: true, |
| 561 | }, |
| 562 | { |
| 563 | name: "no env vars, config has tenancy host", |
| 564 | cfgString: "hosts:\n my-company.ghe.com:\n oauth_token: abc123\n", |
| 565 | want: false, |
| 566 | }, |
| 567 | { |
| 568 | name: "GH_HOST set to enterprise host", |
| 569 | env: map[string]string{"GH_HOST": "ghes.example.com"}, |
| 570 | want: true, |
| 571 | }, |
| 572 | { |
| 573 | name: "GH_HOST set to github.com", |
| 574 | env: map[string]string{"GH_HOST": "github.com"}, |
| 575 | want: false, |
| 576 | }, |
| 577 | { |
| 578 | name: "GH_HOST set to tenancy host", |
| 579 | env: map[string]string{"GH_HOST": "my-company.ghe.com"}, |
| 580 | want: false, |
| 581 | }, |
| 582 | } |
| 583 |
nothing calls this directly
no test coverage detected