Skip to content

Commit c36bf77

Browse files
committed
fix: use getBaseURL in acc_test.go to match provider URL parsing
acc_test.go was parsing GITHUB_BASE_URL with url.Parse() directly, bypassing the normalization done by getBaseURL() in the provider. This caused the test base URL to differ from what the provider produces (e.g. missing trailing slash, no github.com → api.github.com rewrite, no ghe.com API host prefix). Additionally, IsGHES was never set on the test Config, so GHES-specific behavior was not exercised in tests.
1 parent 1af72d4 commit c36bf77

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

github/acc_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var (
3535
type testAccConfig struct {
3636
// Target configuration
3737
baseURL *url.URL
38+
isGHES bool
3839

3940
// Auth configuration
4041
authMode testMode
@@ -100,19 +101,15 @@ func TestMain(m *testing.M) {
100101
authMode = anonymous
101102
}
102103

103-
u, ok := os.LookupEnv("GITHUB_BASE_URL")
104-
if !ok {
105-
u = DotComAPIURL
106-
}
107-
108-
baseURL, err := url.Parse(u)
104+
baseURL, isGHES, err := getBaseURL(os.Getenv("GITHUB_BASE_URL"))
109105
if err != nil {
110106
fmt.Printf("Error parsing base URL: %s\n", err)
111107
os.Exit(1)
112108
}
113109

114110
config := testAccConfig{
115111
baseURL: baseURL,
112+
isGHES: isGHES,
116113
authMode: authMode,
117114
testPublicRepository: "terraform-provider-github",
118115
testPublicRepositoryOwner: "integrations",
@@ -194,6 +191,7 @@ func getTestMeta() (*Owner, error) {
194191
Token: testAccConf.token,
195192
Owner: testAccConf.owner,
196193
BaseURL: testAccConf.baseURL,
194+
IsGHES: testAccConf.isGHES,
197195
}
198196

199197
meta, err := config.Meta()

0 commit comments

Comments
 (0)