From 6315231888ff62e9d1343f0263a0f40e238a4976 Mon Sep 17 00:00:00 2001 From: ManApart Date: Fri, 29 Dec 2023 14:08:28 -0500 Subject: [PATCH] poor man's test mocking --- src/main/kotlin/Main.kt | 2 ++ src/test/kotlin/commands/OrderTest.kt | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index 7ca7287..5caeec3 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -9,6 +9,7 @@ lateinit var modFolder: File val HOME = System.getProperty("user.home")!! val CONFIG_PATH = configPath() var confirmation: ((List) -> Unit)? = null +var testingMode = false val jsonMapper = kotlinx.serialization.json.Json { ignoreUnknownKeys = true @@ -52,6 +53,7 @@ private fun loadData() { } fun save() { + if (testingMode) return File(CONFIG_PATH).writeText(jsonMapper.encodeToString(toolConfig)) File("./data.json").writeText(jsonMapper.encodeToString(toolData)) } diff --git a/src/test/kotlin/commands/OrderTest.kt b/src/test/kotlin/commands/OrderTest.kt index 5f6000c..5f49b88 100644 --- a/src/test/kotlin/commands/OrderTest.kt +++ b/src/test/kotlin/commands/OrderTest.kt @@ -1,10 +1,19 @@ package commands import Mod +import org.junit.jupiter.api.BeforeAll +import testingMode import kotlin.test.Test import kotlin.test.assertEquals class OrderTest { + companion object { + @JvmStatic + @BeforeAll + fun setup() { + testingMode = true + } + } @Test fun modsAreNotNegativeOrdered() {