(t *testing.T)
| 392 | } |
| 393 | |
| 394 | func getGithubAuthToken(t *testing.T) string { |
| 395 | // check if token is set via environment variable |
| 396 | if token := os.Getenv("RILL_TEST_GH_TOKEN"); token != "" { |
| 397 | return token |
| 398 | } |
| 399 | // exec gh auth token and extract token |
| 400 | // throw error if gh cli is not installed |
| 401 | t.Helper() |
| 402 | |
| 403 | // Try to find gh in PATH first |
| 404 | ghPath, err := exec.LookPath("gh") |
| 405 | if err != nil { |
| 406 | // Fallback to common installation paths |
| 407 | commonPaths := []string{ |
| 408 | "/opt/homebrew/bin/gh", |
| 409 | "/usr/local/bin/gh", |
| 410 | "/usr/bin/gh", |
| 411 | } |
| 412 | for _, path := range commonPaths { |
| 413 | if _, err := os.Stat(path); err == nil { |
| 414 | ghPath = path |
| 415 | break |
| 416 | } |
| 417 | } |
| 418 | if ghPath == "" { |
| 419 | t.Fatal("gh cli not found in PATH or common installation paths. For installation instructions, visit: https://github.com/cli/cli#installation") |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | cmd := exec.CommandContext(t.Context(), ghPath, "auth", "token") |
| 424 | output, err := cmd.CombinedOutput() |
| 425 | require.NoError(t, err, "failed to get github auth token: %s", string(output)) |
| 426 | return strings.TrimSpace(string(output)) |
| 427 | } |
| 428 | |
| 429 | func putFiles(t *testing.T, baseDir string, files map[string]string) { |
| 430 | for path, content := range files { |
no test coverage detected