(t *testing.T)
| 272 | } |
| 273 | |
| 274 | func TestGetNpmBinPathSetup(t *testing.T) { |
| 275 | pathSetup := GetNpmBinPathSetup() |
| 276 | |
| 277 | // Should require RUNNER_TOOL_CACHE instead of guessing fallback paths. |
| 278 | if !strings.Contains(pathSetup, "RUNNER_TOOL_CACHE must be set") { |
| 279 | t.Errorf("PATH setup should require RUNNER_TOOL_CACHE, got: %s", pathSetup) |
| 280 | } |
| 281 | if strings.Contains(pathSetup, ":-/opt/hostedtoolcache") { |
| 282 | t.Errorf("PATH setup should not fall back to /opt/hostedtoolcache, got: %s", pathSetup) |
| 283 | } |
| 284 | if strings.Contains(pathSetup, "/home/runner/work/_tool") { |
| 285 | t.Errorf("PATH setup should not hard-code /home/runner/work/_tool, got: %s", pathSetup) |
| 286 | } |
| 287 | |
| 288 | // Should search for bin directories |
| 289 | if !strings.Contains(pathSetup, "-name bin") { |
| 290 | t.Errorf("PATH setup should search for bin directories, got: %s", pathSetup) |
| 291 | } |
| 292 | if !strings.Contains(pathSetup, "-maxdepth 5") { |
| 293 | t.Errorf("PATH setup should search deep enough for setup-node toolcache bins, got: %s", pathSetup) |
| 294 | } |
| 295 | |
| 296 | // Should preserve existing PATH |
| 297 | if !strings.Contains(pathSetup, "$PATH") { |
| 298 | t.Errorf("PATH setup should include $PATH, got: %s", pathSetup) |
| 299 | } |
| 300 | |
| 301 | // Should re-prepend GOROOT/bin after the find to preserve correct Go version ordering |
| 302 | // (find returns alphabetically, so go/1.23 can shadow go/1.25) |
| 303 | if !strings.Contains(pathSetup, "$GOROOT") { |
| 304 | t.Errorf("PATH setup should re-prepend GOROOT/bin after find, got: %s", pathSetup) |
| 305 | } |
| 306 | |
| 307 | // GOROOT re-prepend should come AFTER the find command |
| 308 | findIdx := strings.Index(pathSetup, `find "$GH_AW_TOOL_CACHE"`) |
| 309 | gorootIdx := strings.Index(pathSetup, "$GOROOT") |
| 310 | if findIdx < 0 { |
| 311 | t.Errorf("PATH setup should search GH_AW_TOOL_CACHE, got: %s", pathSetup) |
| 312 | } |
| 313 | if gorootIdx < findIdx { |
| 314 | t.Errorf("GOROOT re-prepend should come after find command, got: %s", pathSetup) |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | // TestGetNpmBinPathSetup_GorootOrdering verifies that GOROOT/bin takes precedence |
| 319 | // over alphabetically-ordered Go versions in hostedtoolcache. |
nothing calls this directly
no test coverage detected