Skip to content

Commit

Permalink
poor man's test mocking
Browse files Browse the repository at this point in the history
  • Loading branch information
ManApart committed Dec 29, 2023
1 parent e16ec3d commit 6315231
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ lateinit var modFolder: File
val HOME = System.getProperty("user.home")!!
val CONFIG_PATH = configPath()
var confirmation: ((List<String>) -> Unit)? = null
var testingMode = false

val jsonMapper = kotlinx.serialization.json.Json {
ignoreUnknownKeys = true
Expand Down Expand Up @@ -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))
}
Expand Down
9 changes: 9 additions & 0 deletions src/test/kotlin/commands/OrderTest.kt
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down

0 comments on commit 6315231

Please sign in to comment.