(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func 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 | |
| 62 | func TestSearch(t *testing.T) { |
| 63 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…