summaryrefslogtreecommitdiff
path: root/libs/test-utils/src
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2024-11-09 18:43:29 +0100
committerJoel Klinghed <the_jk@spawned.biz>2024-11-09 18:43:29 +0100
commit6e6cbe2a611203ef651878dbfe97eb7ce5fda516 (patch)
tree53808ae0eb5151f8e2c94fbc4ca1d6dd1040b3f7 /libs/test-utils/src
parent78219cc5219b364b17df48bd20e636bcfec39cc4 (diff)
documents: Allow many methods to take a path, not just a name
Can't create entries with "/" in for the other backends, so they will resolve the path. documents would not. Change that so they are more similar.
Diffstat (limited to 'libs/test-utils/src')
-rw-r--r--libs/test-utils/src/main/java/org/the_jk/cleversync/TreeAbstractTest.kt51
1 files changed, 51 insertions, 0 deletions
diff --git a/libs/test-utils/src/main/java/org/the_jk/cleversync/TreeAbstractTest.kt b/libs/test-utils/src/main/java/org/the_jk/cleversync/TreeAbstractTest.kt
index a82001c..0a0b32d 100644
--- a/libs/test-utils/src/main/java/org/the_jk/cleversync/TreeAbstractTest.kt
+++ b/libs/test-utils/src/main/java/org/the_jk/cleversync/TreeAbstractTest.kt
@@ -439,6 +439,57 @@ abstract class TreeAbstractTest {
assertThat(content.files[0].name).isEqualTo(file.name)
}
+ @Test
+ open fun openDirInDir() {
+ val foo = tree.createDirectory("foo")
+ val bar = foo.createDirectory("bar")
+ val fooBar = tree.openDir("foo/bar")
+ assertThat(fooBar).isEqualTo(bar)
+ }
+
+ @Test
+ open fun openFileInDir() {
+ val foo = tree.createDirectory("foo")
+ val bar = foo.createFile("bar")
+ bar.write().use { it.write(1) }
+ val fooBar = tree.openFile("foo/bar")
+ assertThat(fooBar).isEqualTo(bar)
+ }
+
+ @Test
+ open fun createDirInDir() {
+ val foo = tree.createDirectory("foo")
+ val fooBar = tree.createDirectory("foo/bar")
+ val bar = foo.openDir("bar")
+ assertThat(bar).isEqualTo(fooBar)
+ }
+
+ @Test
+ open fun createFileInDir() {
+ val foo = tree.createDirectory("foo")
+ val fooBar = tree.createFile("foo/bar")
+ fooBar.write().use { it.write(1) }
+ val bar = foo.openFile("bar")
+ assertThat(bar).isEqualTo(fooBar)
+ }
+
+ @Test
+ open fun removeDirInDir() {
+ val foo = tree.createDirectory("foo")
+ foo.createDirectory("bar")
+ assertThat(tree.removeDirectory("foo/bar")).isTrue()
+ assertThat(foo.list().directories).isEmpty()
+ }
+
+ @Test
+ open fun removeFileInDir() {
+ val foo = tree.createDirectory("foo")
+ val bar = foo.createFile("bar")
+ bar.write().use { it.write(1) }
+ assertThat(tree.removeFile("foo/bar")).isTrue()
+ assertThat(foo.list().files).isEmpty()
+ }
+
protected abstract fun supportSymlinks(): Boolean
protected abstract fun idle()