From 6e6cbe2a611203ef651878dbfe97eb7ce5fda516 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Sat, 9 Nov 2024 18:43:29 +0100 Subject: 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. --- .../java/org/the_jk/cleversync/TreeAbstractTest.kt | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'libs/test-utils') 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() -- cgit v1.2.3-70-g09d2