Skip to content

Commit

Permalink
Update FileManagerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
esotericenderman committed Oct 29, 2024
1 parent 6e987b6 commit 04d19b1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package foundation.esoteric.minecraft.plugins.library.file
import be.seeseemelk.mockbukkit.MockBukkit
import foundation.esoteric.minecraft.plugins.library.TestPlugin
import java.io.File
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertTrue
import kotlin.test.*

class FileManagerTest {

Expand All @@ -19,9 +17,36 @@ class FileManagerTest {
}

@Test fun savingFolderWorks() {
fileManager.saveResourceFolder("file/FileManagerTest")
fileManager.saveResourceFolder("file/FileManagerTest/1")

assertTrue(File(plugin.dataFolder, "file").exists())
assertTrue(File(plugin.dataFolder, "file/FileManagerTest").exists())
val fileDir = File(plugin.dataFolder, "file")
val fileManagerTestDir = File(fileDir, "FileManagerTest")
val testOneDir = File(fileManagerTestDir, "1")

val testFileOne = File(testOneDir, "Test File 1.txt")
val testFileTwo = File(testOneDir, "Test File 2.txt")

assertTrue(fileDir.exists())
assertTrue(fileDir.isDirectory)
assertNotNull(fileDir.listFiles())
assertEquals(fileDir.listFiles()!!.size, 1)

assertTrue(fileManagerTestDir.exists())
assertTrue(fileManagerTestDir.isDirectory)
assertNotNull(fileManagerTestDir.listFiles())
assertEquals(fileManagerTestDir.listFiles()!!.size, 1)

assertTrue(testOneDir.exists())
assertTrue(testOneDir.isDirectory)
assertNotNull(testOneDir.listFiles())
assertEquals(testOneDir.listFiles()!!.size, 2)

assertTrue(testFileOne.exists())
assertFalse(testFileOne.isDirectory)
assertEquals(testFileOne.readText(), "This file is used to test the FileManager.\r\n")

assertTrue(testFileTwo.exists())
assertFalse(testFileTwo.isDirectory)
assertEquals(testFileTwo.readText(), "This file is used to test the FileManager.\r\n")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file is used to test the FileManager.

0 comments on commit 04d19b1

Please sign in to comment.