MCPcopy Index your code
hub / github.com/pocketbase/pocketbase / TestIsProbablyGoRun

Function TestIsProbablyGoRun

tools/osutils/run_test.go:9–45  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestIsProbablyGoRun(t *testing.T) {
10 scenarios := []struct {
11 arg0 string
12 runDirs []string
13 expected bool
14 }{
15 {"", nil, false},
16 {"/a/b", nil, false},
17 {"/a/b", []string{""}, false},
18 {"/a/b", []string{"/b/"}, false},
19 {"/a/b", []string{"/a/"}, true},
20 {"/a/b", []string{"", "/b/", "/a/"}, true},
21 }
22
23 originalArgs := os.Args
24 defer func() {
25 os.Args = originalArgs
26 }()
27
28 originalRunDirs := runDirs
29 defer func() {
30 runDirs = originalRunDirs
31 }()
32
33 for i, s := range scenarios {
34 t.Run(strconv.Itoa(i)+"_"+s.arg0, func(t *testing.T) {
35 os.Args = []string{s.arg0}
36 runDirs = s.runDirs
37
38 result := IsProbablyGoRun()
39
40 if result != s.expected {
41 t.Fatalf("Expected %v, got %v", s.expected, result)
42 }
43 })
44 }
45}

Callers

nothing calls this directly

Calls 2

IsProbablyGoRunFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…