summaryrefslogtreecommitdiff
path: root/crawl/crawl_test.go
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-04-14 16:37:17 +0200
committerewy <ewy0@protonmail.com>2026-04-14 16:37:17 +0200
commit45a297a8e526094e8fce6e2c5c0fd89b381d1765 (patch)
tree852ebc3a0112c94dc9726d0b27ab057bf6383660 /crawl/crawl_test.go
i have to commit at some point!
Diffstat (limited to 'crawl/crawl_test.go')
-rw-r--r--crawl/crawl_test.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/crawl/crawl_test.go b/crawl/crawl_test.go
new file mode 100644
index 0000000..88b70f1
--- /dev/null
+++ b/crawl/crawl_test.go
@@ -0,0 +1,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"))
+}