Skip to content

Commit

Permalink
Add plugin utility test
Browse files Browse the repository at this point in the history
  • Loading branch information
esotericenderman committed Nov 3, 2024
1 parent 4f13e71 commit 1ca6441
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package foundation.esoteric.minecraft.plugins.library.utility.plugin

import be.seeseemelk.mockbukkit.MockBukkit
import foundation.esoteric.minecraft.plugins.library.TestPlugin
import java.io.File
import kotlin.io.path.Path
import kotlin.test.*

class PluginUtilityTest {

private lateinit var plugin: TestPlugin

@BeforeTest fun mockPlugin() {
MockBukkit.mock()
plugin = MockBukkit.load(TestPlugin::class.java)
}

@Test fun savingFolderWorks() {
val resourcesPath = Path("TestPluginResourcePack")
val file = File(plugin.dataFolder, resourcesPath.toString())

plugin.saveResources(resourcesPath)
assertTrue(file.exists())
assertTrue(file.isDirectory)
assertFalse(file.isFile)
assertNotNull(file.listFiles())
assertEquals(1, file.listFiles()!!.size)

val packFile = File(file, "pack.mcmeta")
assertTrue(packFile.exists())
assertTrue(packFile.isFile)
assertFalse(packFile.isDirectory)
}

@AfterTest fun unmockPlugin() {
MockBukkit.unmock()
}
}

0 comments on commit 1ca6441

Please sign in to comment.