summaryrefslogtreecommitdiff
path: root/libs/utils/src/test
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2024-11-09 16:17:44 +0100
committerJoel Klinghed <the_jk@spawned.biz>2024-11-09 16:17:44 +0100
commit882520f3baee410647c3b99d608cc8fe18b0f5d0 (patch)
treeeebb370a4977ea20ce3cfaf679aff387ab0896c9 /libs/utils/src/test
parent6ea5cef180db16523b2d629a44ee556507e3de78 (diff)
sftp: add single merge tests for both local <-> sftp and sftp <-> local
Had to fixup the symlink code in Sftp, most importantly add a PathUtils relativeTo to fixup relative links.
Diffstat (limited to 'libs/utils/src/test')
-rw-r--r--libs/utils/src/test/java/org/the_jk/cleversync/PathUtilsTest.kt11
1 files changed, 11 insertions, 0 deletions
diff --git a/libs/utils/src/test/java/org/the_jk/cleversync/PathUtilsTest.kt b/libs/utils/src/test/java/org/the_jk/cleversync/PathUtilsTest.kt
index eb1d63f..1d411ea 100644
--- a/libs/utils/src/test/java/org/the_jk/cleversync/PathUtilsTest.kt
+++ b/libs/utils/src/test/java/org/the_jk/cleversync/PathUtilsTest.kt
@@ -55,4 +55,15 @@ class PathUtilsTest {
assertThat(PathUtils.resolve("foo/../../../bar/")).isEqualTo("bar")
assertThat(PathUtils.resolve("/foo/../../../bar/")).isEqualTo("/bar")
}
+
+ @Test
+ fun relativeTo() {
+ assertThat(PathUtils.relativeTo("", "")).isEmpty()
+ assertThat(PathUtils.relativeTo("/", "/")).isEqualTo(".")
+ assertThat(PathUtils.relativeTo("/", "/foo")).isEqualTo("foo")
+ assertThat(PathUtils.relativeTo("/", "/foo/bar/")).isEqualTo("foo/bar")
+ assertThat(PathUtils.relativeTo("/foo", "/foo/bar/")).isEqualTo("bar")
+ assertThat(PathUtils.relativeTo("/foo", "/bar")).isEqualTo("../bar")
+ assertThat(PathUtils.relativeTo("/foo/bar", "/fum/bar")).isEqualTo("../../fum/bar")
+ }
}