mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-10-09 15:57:26 +02:00
check the default user cachedir if GOCACHE is not explicitly set
This commit is contained in:
1 parent
40f2ba731c
commit
eda90d4555
4 files changed
+78
-51
No files matched your search
@@ -64,40 +64,3 @@ func TestYesNoPrompt(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsProbablyGoRun(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
arg string
|
||||
envs map[string]string
|
||||
expected bool
|
||||
}{
|
||||
{"", nil, false},
|
||||
{"a/b/c", nil, false},
|
||||
{"/a/b/c", nil, false},
|
||||
{"/a/b/c", map[string]string{"GOCACHE": "/b/"}, false},
|
||||
{"/a/b/c", map[string]string{"GOCACHE": "/a/"}, true},
|
||||
{os.TempDir() + "/a/b/c", nil, true},
|
||||
}
|
||||
|
||||
originalArgs := os.Args
|
||||
defer func() {
|
||||
os.Args = originalArgs
|
||||
}()
|
||||
|
||||
for _, s := range scenarios {
|
||||
t.Run(s.arg, func(t *testing.T) {
|
||||
os.Args = []string{s.arg}
|
||||
|
||||
for k, v := range s.envs {
|
||||
defer os.Setenv(k, os.Getenv(k))
|
||||
os.Setenv(k, v)
|
||||
}
|
||||
|
||||
result := osutils.IsProbablyGoRun()
|
||||
|
||||
if result != s.expected {
|
||||
t.Fatalf("Expected %v, got %v", s.expected, result)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user