diff options
Diffstat (limited to 'app/src/test')
| -rw-r--r-- | app/src/test/java/org/the_jk/cleversync/LocalTreeTest.kt | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/app/src/test/java/org/the_jk/cleversync/LocalTreeTest.kt b/app/src/test/java/org/the_jk/cleversync/LocalTreeTest.kt index d9a9bd8..951fd62 100644 --- a/app/src/test/java/org/the_jk/cleversync/LocalTreeTest.kt +++ b/app/src/test/java/org/the_jk/cleversync/LocalTreeTest.kt @@ -29,9 +29,17 @@ class LocalTreeTest { @Test fun empty() { val content = tree.list() - assertThat(content.directories.safeValue()).isEmpty() - assertThat(content.files.safeValue()).isEmpty() - assertThat(content.links.safeValue()).isEmpty() + assertThat(content.directories).isEmpty() + assertThat(content.files).isEmpty() + assertThat(content.links).isEmpty() + } + + @Test + fun emptyLive() { + val content = tree.liveList().safeValue() + assertThat(content?.directories).isEmpty() + assertThat(content?.files).isEmpty() + assertThat(content?.links).isEmpty() } @Test @@ -39,21 +47,21 @@ class LocalTreeTest { val foo = tree.createDirectory("foo") assertThat(foo.name).isEqualTo("foo") val fooContent = foo.list() - assertThat(fooContent.directories.safeValue()).isEmpty() - assertThat(fooContent.files.safeValue()).isEmpty() - assertThat(fooContent.links.safeValue()).isEmpty() + assertThat(fooContent.directories).isEmpty() + assertThat(fooContent.files).isEmpty() + assertThat(fooContent.links).isEmpty() val content = tree.list() - assertThat(content.directories.safeValue()).contains(foo) - assertThat(content.files.safeValue()).isEmpty() - assertThat(content.links.safeValue()).isEmpty() + assertThat(content.directories).contains(foo) + assertThat(content.files).isEmpty() + assertThat(content.links).isEmpty() } @Test fun observeCreateDirectory() { - val content = tree.list() + val content = tree.liveList() var dir: Directory? = null - content.directories.observeForever { list -> - if (list.size == 1) dir = list[0] + content.observeForever { + if (it.directories.size == 1) dir = it.directories[0] } tree.createDirectory("foo") while (dir == null) { @@ -66,11 +74,11 @@ class LocalTreeTest { fun createFile() { val foo = tree.createFile("foo") // Files are not created until you write to them. - assertThat(tree.list().files.safeValue()).isEmpty() + assertThat(tree.list().files).isEmpty() foo.write().use { os -> os.write(byteArrayOf(1, 2, 3, 4)) } - assertThat(tree.list().files.safeValue()).contains(foo) + assertThat(tree.list().files).contains(foo) assertThat(foo.size).isEqualTo(4.toULong()) foo.read().use { assertThat(it.readBytes()).isEqualTo(byteArrayOf(1, 2, 3, 4)) @@ -88,7 +96,7 @@ class LocalTreeTest { assertThat(foo.size).isEqualTo(4.toULong()) } assertThat(foo.size).isEqualTo(1.toULong()) - assertThat(tree.list().files.safeValue()).hasSize(1) + assertThat(tree.list().files).hasSize(1) foo.read().use { assertThat(it.readBytes()).isEqualTo(byteArrayOf(127)) } |
