(t *testing.T)
| 142 | } |
| 143 | |
| 144 | func TestResolveDir(t *testing.T) { |
| 145 | t.Parallel() |
| 146 | |
| 147 | wd, err := os.Getwd() |
| 148 | require.NoError(t, err) |
| 149 | |
| 150 | tests := []struct { |
| 151 | name string |
| 152 | entrypoint string |
| 153 | resolvedEntrypoint string |
| 154 | dir string |
| 155 | expectedDir string |
| 156 | }{ |
| 157 | { |
| 158 | name: "find foo.txt using relative entrypoint", |
| 159 | entrypoint: "./testdata/foo.txt", |
| 160 | resolvedEntrypoint: filepath.Join(wd, "testdata", "foo.txt"), |
| 161 | expectedDir: filepath.Join(wd, "testdata"), |
| 162 | }, |
| 163 | { |
| 164 | name: "find foo.txt using absolute entrypoint", |
| 165 | entrypoint: filepath.Join(wd, "testdata", "foo.txt"), |
| 166 | resolvedEntrypoint: filepath.Join(wd, "testdata", "foo.txt"), |
| 167 | expectedDir: filepath.Join(wd, "testdata"), |
| 168 | }, |
| 169 | { |
| 170 | name: "find foo.txt using relative dir", |
| 171 | resolvedEntrypoint: filepath.Join(wd, "testdata", "foo.txt"), |
| 172 | dir: "./testdata", |
| 173 | expectedDir: filepath.Join(wd, "testdata"), |
| 174 | }, |
| 175 | { |
| 176 | name: "find foo.txt using absolute dir", |
| 177 | resolvedEntrypoint: filepath.Join(wd, "testdata", "foo.txt"), |
| 178 | dir: filepath.Join(wd, "testdata"), |
| 179 | expectedDir: filepath.Join(wd, "testdata"), |
| 180 | }, |
| 181 | { |
| 182 | name: "find foo.txt using relative dir and relative entrypoint", |
| 183 | entrypoint: "./testdata/foo.txt", |
| 184 | resolvedEntrypoint: filepath.Join(wd, "testdata", "foo.txt"), |
| 185 | dir: "./testdata/some/other/dir", |
| 186 | expectedDir: filepath.Join(wd, "testdata", "some", "other", "dir"), |
| 187 | }, |
| 188 | { |
| 189 | name: "find fs.go using no entrypoint or dir", |
| 190 | entrypoint: "", |
| 191 | resolvedEntrypoint: filepath.Join(wd, "fs.go"), |
| 192 | dir: "", |
| 193 | expectedDir: wd, |
| 194 | }, |
| 195 | { |
| 196 | name: "find ../../Taskfile.yml using no entrypoint or dir by walking", |
| 197 | entrypoint: "", |
| 198 | resolvedEntrypoint: filepath.Join(wd, "..", "..", "Taskfile.yml"), |
| 199 | dir: "", |
| 200 | expectedDir: filepath.Join(wd, "..", ".."), |
| 201 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…