(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestGetGitHubHostForRepo_PublicOrgFallback(t *testing.T) { |
| 12 | tests := []struct { |
| 13 | name string |
| 14 | owner string |
| 15 | repo string |
| 16 | gheHost string |
| 17 | expectedHost string |
| 18 | }{ |
| 19 | { |
| 20 | name: "non-fallback owner uses configured host", |
| 21 | owner: "acme", |
| 22 | repo: "repo", |
| 23 | gheHost: "myorg.ghe.com", |
| 24 | expectedHost: "https://myorg.ghe.com", |
| 25 | }, |
| 26 | { |
| 27 | name: "github owner uses public host", |
| 28 | owner: "github", |
| 29 | repo: "copilot", |
| 30 | gheHost: "myorg.ghe.com", |
| 31 | expectedHost: "https://github.com", |
| 32 | }, |
| 33 | { |
| 34 | name: "githubnext owner uses public host", |
| 35 | owner: "githubnext", |
| 36 | repo: "agentics", |
| 37 | gheHost: "myorg.ghe.com", |
| 38 | expectedHost: "https://github.com", |
| 39 | }, |
| 40 | { |
| 41 | name: "microsoft owner uses public host", |
| 42 | owner: "microsoft", |
| 43 | repo: "vscode", |
| 44 | gheHost: "myorg.ghe.com", |
| 45 | expectedHost: "https://github.com", |
| 46 | }, |
| 47 | } |
| 48 | |
| 49 | for _, tt := range tests { |
| 50 | t.Run(tt.name, func(t *testing.T) { |
| 51 | t.Setenv("GITHUB_SERVER_URL", "") |
| 52 | t.Setenv("GITHUB_ENTERPRISE_HOST", tt.gheHost) |
| 53 | t.Setenv("GITHUB_HOST", "") |
| 54 | t.Setenv("GH_HOST", "") |
| 55 | |
| 56 | host := GetGitHubHostForRepo(tt.owner, tt.repo) |
| 57 | assert.Equal(t, tt.expectedHost, host, "GetGitHubHostForRepo(%q, %q)", tt.owner, tt.repo) |
| 58 | }) |
| 59 | } |
| 60 | } |
nothing calls this directly
no test coverage detected