forked from golangci/golangci-lint
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfsutils_test.go
42 lines (36 loc) · 827 Bytes
/
fsutils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package fsutils
import (
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestShortestRelPath(t *testing.T) {
testCases := []struct {
desc string
path string
wd string
expected string
}{
{
desc: "based on parent path",
path: "fsutils_test.go",
wd: filepath.Join("..", "fsutils"),
expected: "fsutils_test.go",
},
{
desc: "based on current working directory",
path: "fsutils_test.go",
wd: "",
expected: "fsutils_test.go",
},
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
rel, err := ShortestRelPath("fsutils_test.go", filepath.Join("..", "fsutils"))
require.NoError(t, err)
assert.Equal(t, test.expected, rel)
})
}
}