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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package crawl
import (
"github.com/stretchr/testify/assert"
"io/fs"
"testing"
)
func TestParentDir(t *testing.T) {
input := "/var/lib"
parent := ParentDir(input)
assert.Equal(t, parent, "/var/")
}
func TestParentDir_TrailingSlash(t *testing.T) {
input := "/var/lib/"
parent := ParentDir(input)
assert.Equal(t, parent, "/var/")
}
func TestParentDir_ToRoot(t *testing.T) {
input := "/var/"
parent := ParentDir(input)
assert.Equal(t, parent, "/")
}
func TestParentDir_ToRoot_NoTrailingSlash(t *testing.T) {
input := "/var"
parent := ParentDir(input)
assert.Equal(t, parent, "/")
}
func TestParentDir_WithoutParent(t *testing.T) {
input := "/"
parent := ParentDir(input)
assert.Equal(t, parent, "/")
}
func TestLocations(t *testing.T) {
input := "/var/lib/uwu/asdf"
locs := Locations(input)
assert.Equal(t, locs, []string{"/var/lib/uwu/asdf", "/var/lib/uwu/", "/var/lib/", "/var/", "/"})
}
func TestLocations_WithDotPath(t *testing.T) {
input := "/root/./second/asdf/../third"
locs := Locations(input)
assert.Equal(t, locs, []string{"/root/second/third", "/root/second/", "/root/", "/"})
}
func TestLocations_HighestFirst(t *testing.T) {
input := "/one/two/three"
locs := Locations(input)
assert.Equal(t, locs[0], "/one/two/three")
}
func Test(t *testing.T) {
assert.True(t, fs.ValidPath("asdf/hjkl"))
}
|