MCPcopy Index your code
hub / github.com/maruel/panicparse / TestGetGOPATHs

Function TestGetGOPATHs

stack/context_test.go:1427–1450  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1425}
1426
1427func TestGetGOPATHs(t *testing.T) {
1428 // This test cannot run in parallel.
1429 old := os.Getenv("GOPATH")
1430 defer os.Setenv("GOPATH", old)
1431 os.Setenv("GOPATH", "")
1432 if p := getGOPATHs(); len(p) != 1 {
1433 // It's the home directory + /go.
1434 t.Fatalf("expected only one path: %v", p)
1435 }
1436
1437 root, err := os.MkdirTemp("", "stack")
1438 if err != nil {
1439 t.Fatal(err)
1440 }
1441 defer func() {
1442 if err = os.RemoveAll(root); err != nil {
1443 t.Error(err)
1444 }
1445 }()
1446 os.Setenv("GOPATH", filepath.Join(root, "a")+string(filepath.ListSeparator)+filepath.Join(root, "b")+string(filepath.Separator))
1447 if p := getGOPATHs(); len(p) != 2 {
1448 t.Fatalf("expected two paths: %v", p)
1449 }
1450}
1451
1452// TestGomoduleComplex is an integration test that creates a non-trivial tree
1453// of go modules using the "replace" statement.

Callers

nothing calls this directly

Calls 1

getGOPATHsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…