Add more test for PermanentFileStorage.

Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This commit is contained in:
Yahor Berdnikau 2018-03-11 19:13:01 +01:00
parent 1e806e3658
commit 63715aab18
2 changed files with 8 additions and 3 deletions

View File

@ -55,9 +55,7 @@ class PermanentFileStorage(
*/
fun clearAll() {
val storageDir = getStorageDir()
if (storageDir.exists()) {
storageDir.listFiles().forEach { if (it.isFile) it.delete() }
}
storageDir.listFiles().forEach { it.deleteRecursively() }
}
private fun getFile(name: String) = File(getStorageDir(), "$name.ser")

View File

@ -64,4 +64,11 @@ class PermanentFileStorageTest : BaseStorageTest() {
storageDir.listFiles().size `should equal to` 0
}
@Test
fun `Should return null if serialized file not available`() {
val loadedItem = storage.load("some-name", musicFolderSerializer)
loadedItem `should equal` null
}
}