MCPcopy
hub / github.com/go-task/task / TestDefaultDir

Function TestDefaultDir

internal/fsext/fs_test.go:11–60  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestDefaultDir(t *testing.T) {
12 t.Parallel()
13
14 wd, err := os.Getwd()
15 require.NoError(t, err)
16
17 tests := []struct {
18 name string
19 entrypoint string
20 dir string
21 expected string
22 }{
23 {
24 name: "default to current working directory",
25 entrypoint: "",
26 dir: "",
27 expected: wd,
28 },
29 {
30 name: "resolves relative dir path",
31 entrypoint: "",
32 dir: "./dir",
33 expected: filepath.Join(wd, "dir"),
34 },
35 {
36 name: "return entrypoint if set",
37 entrypoint: filepath.Join(wd, "entrypoint"),
38 dir: "",
39 expected: "",
40 },
41 {
42 name: "if entrypoint and dir are set",
43 entrypoint: filepath.Join(wd, "entrypoint"),
44 dir: filepath.Join(wd, "dir"),
45 expected: filepath.Join(wd, "dir"),
46 },
47 {
48 name: "if entrypoint and dir are set and dir is relative",
49 entrypoint: filepath.Join(wd, "entrypoint"),
50 dir: "./dir",
51 expected: filepath.Join(wd, "dir"),
52 },
53 }
54 for _, tt := range tests {
55 t.Run(tt.name, func(t *testing.T) {
56 t.Parallel()
57 require.Equal(t, tt.expected, DefaultDir(tt.entrypoint, tt.dir))
58 })
59 }
60}
61
62func TestSearch(t *testing.T) {
63 t.Parallel()

Callers

nothing calls this directly

Calls 2

DefaultDirFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…