summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2021-08-16 16:04:39 +0200
committernea <romangraef@gmail.com>2021-08-16 16:04:39 +0200
commitc7d1477e3d8e5db7e504c38af7ee0a3113adae43 (patch)
tree0deab315759637dbaa09b89030e0101432399183
parent5cce0241d1e323e946144fc97989f9f9b5af1acb (diff)
downloadwebos-c7d1477e3d8e5db7e504c38af7ee0a3113adae43.tar.gz
webos-c7d1477e3d8e5db7e504c38af7ee0a3113adae43.tar.bz2
webos-c7d1477e3d8e5db7e504c38af7ee0a3113adae43.zip
delete test
-rw-r--r--src/jsTest/kotlin/ProjectConfig.kt6
-rw-r--r--src/jsTest/kotlin/io/FileServiceTest.kt19
2 files changed, 19 insertions, 6 deletions
diff --git a/src/jsTest/kotlin/ProjectConfig.kt b/src/jsTest/kotlin/ProjectConfig.kt
index cf0f15d..faa4d69 100644
--- a/src/jsTest/kotlin/ProjectConfig.kt
+++ b/src/jsTest/kotlin/ProjectConfig.kt
@@ -1,7 +1,3 @@
import io.kotest.core.config.AbstractProjectConfig
-class ProjectConfig : AbstractProjectConfig() {
- override suspend fun beforeProject() {
- println("HELLO")
- }
-}
+class ProjectConfig : AbstractProjectConfig()
diff --git a/src/jsTest/kotlin/io/FileServiceTest.kt b/src/jsTest/kotlin/io/FileServiceTest.kt
index 2ad5ee3..9c9c8b9 100644
--- a/src/jsTest/kotlin/io/FileServiceTest.kt
+++ b/src/jsTest/kotlin/io/FileServiceTest.kt
@@ -12,6 +12,7 @@ class FileServiceTest : FunSpec({
fun <INode> FunSpec.generateTests(name: String, provider: () -> FileService<INode>) {
val aPath = Path.of("/a") as Path.Absolute
+ val bPath = Path.of("/a/b") as Path.Absolute
val homePath = Path.of("/roothome") as Path.Absolute
val dataA = "a".encodeToByteArray()
val rootUser = User("root", homePath, true)
@@ -19,6 +20,7 @@ fun <INode> FunSpec.generateTests(name: String, provider: () -> FileService<INod
val fileService = provider()
val rootInode = fileService.getINode(Path.root)
assertTrue(fileService.exists(rootInode))
+ assertEquals(fileService.getPath(rootInode), Path.root)
}
test("$name: CRUD a file") {
val fileService = provider()
@@ -38,5 +40,20 @@ fun <INode> FunSpec.generateTests(name: String, provider: () -> FileService<INod
assertFalse(fileService.isFile(aInode))
assertFalse(fileService.exists(aInode))
}
-
+ test("$name: CRUD a directory structure") {
+ val fileService = provider()
+ val aINode = fileService.getINode(aPath)
+ val bINode = fileService.getINode(bPath)
+ assertFalse(fileService.exists(aINode))
+ assertFalse(fileService.exists(bINode))
+ assertEquals(fileService.createDirectory(aINode, rootUser), CreateFileResult.Created)
+ assertEquals(fileService.createFile(bINode, rootUser), CreateFileResult.Created)
+ assertTrue(fileService.exists(aINode))
+ assertTrue(fileService.exists(bINode))
+ assertEquals(fileService.writeToFile(bINode, rootUser, dataA), WriteFileResult.Written)
+ assertEquals(fileService.readFromFile(bINode, rootUser), ReadFileResult.Read(dataA))
+ assertEquals(fileService.deleteFile(aINode, rootUser), DeleteFileResult.Deleted)
+ assertFalse(fileService.exists(bINode))
+ assertFalse(fileService.exists(aINode))
+ }
}