diff --git a/lib/src/test/kotlin/foundation/esoteric/utility/resource/ResourceUtilityTest.kt b/lib/src/test/kotlin/foundation/esoteric/utility/resource/ResourceUtilityTest.kt index 368226a..4988712 100644 --- a/lib/src/test/kotlin/foundation/esoteric/utility/resource/ResourceUtilityTest.kt +++ b/lib/src/test/kotlin/foundation/esoteric/utility/resource/ResourceUtilityTest.kt @@ -1,12 +1,20 @@ package foundation.esoteric.utility.resource +import org.apache.commons.io.FileUtils import org.junit.jupiter.api.assertThrows +import java.io.File import java.nio.file.Path import kotlin.io.path.Path -import kotlin.test.Test -import kotlin.test.assertEquals +import kotlin.test.* class ResourceUtilityTest { + + private var run = File("run") + + @BeforeTest fun createRunDirectory() { + run.mkdir() + } + @Test fun resourcesListIsCorrect() { val resourcePaths = Path("resource").resourceFilePaths() @@ -18,4 +26,19 @@ class ResourceUtilityTest { Path("some random path that does not exist").resourceFilePaths() } } + + @Test fun savingResourcesWorks() { + val saveLocation = File(run, "Test File.txt") + val resourcePath = Path("resource/ResourceUtilityTest/Test File.txt") + resourcePath.saveResource(saveLocation.toPath()) + + assertTrue(saveLocation.exists()) + assertTrue(saveLocation.isFile) + assertFalse(saveLocation.isDirectory) + assertEquals("This file is used to test the resource utility.", saveLocation.readText().trimEnd('\n', '\r')) + } + + @AfterTest fun deleteRunDirectory() { + FileUtils.deleteDirectory(run) + } }