(t *testing.T)
| 378 | } |
| 379 | |
| 380 | func TestEnsureGHESRepoConfig_NoDetection(t *testing.T) { |
| 381 | // Without GH_HOST or GITHUB_SERVER_URL pointing to GHES, and without a git remote, |
| 382 | // ensureGHESRepoConfig should do nothing (detection fails gracefully). |
| 383 | tempDir := t.TempDir() |
| 384 | oldWd, err := os.Getwd() |
| 385 | if err != nil { |
| 386 | t.Fatalf("Failed to get cwd: %v", err) |
| 387 | } |
| 388 | defer func() { _ = os.Chdir(oldWd) }() |
| 389 | if err := os.Chdir(tempDir); err != nil { |
| 390 | t.Fatalf("Failed to chdir: %v", err) |
| 391 | } |
| 392 | |
| 393 | // Set up a git repo with a github.com remote (not GHES) |
| 394 | cmd := exec.Command("git", "init") |
| 395 | cmd.Dir = tempDir |
| 396 | _ = cmd.Run() |
| 397 | cmd = exec.Command("git", "remote", "add", "origin", "https://github.com/owner/repo.git") |
| 398 | cmd.Dir = tempDir |
| 399 | _ = cmd.Run() |
| 400 | |
| 401 | // Unset any env vars that might signal GHES |
| 402 | t.Setenv("GH_HOST", "") |
| 403 | t.Setenv("GITHUB_SERVER_URL", "") |
| 404 | |
| 405 | updated, err := ensureGHESRepoConfig(false) |
| 406 | if err != nil { |
| 407 | t.Fatalf("ensureGHESRepoConfig returned unexpected error: %v", err) |
| 408 | } |
| 409 | if updated { |
| 410 | t.Error("ensureGHESRepoConfig should not update aw.json when not on GHES") |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | func TestEnsureGHESRepoConfig_GHHostEnvVar(t *testing.T) { |
| 415 | // When GH_HOST points to a GHES host, ensureGHESRepoConfig should write aw.json. |
nothing calls this directly
no test coverage detected