File tree Expand file tree Collapse file tree
main/kotlin/net/chariskar/breakthemod/client/utils
test/kotlin/net/chariskar/breakthemod Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,10 +51,12 @@ object Config {
5151 )
5252
5353 private val json = Json { encodeDefaults = true }
54- val configFile: File = File (MinecraftClient .getInstance().runDirectory, " config/breakthemod_config.json" )
54+ val configFile: File = File (MinecraftClient .getInstance()? .runDirectory, " config/breakthemod_config.json" )
5555 val logger: Logger = LoggerFactory .getLogger(" breakthemod" )
5656
5757 fun loadConfig () {
58+ if (MinecraftClient .getInstance() == null ) return
59+
5860 if (! configFile.exists()) { saveConfig(null ) }
5961
6062 val fileContent = configFile.readText()
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import kotlinx.coroutines.CoroutineScope
44import kotlinx.coroutines.Dispatchers
55import kotlinx.coroutines.SupervisorJob
66import kotlinx.coroutines.cancel
7+ import net.chariskar.breakthemod.client.utils.Config
78
89object TestScope {
910 val scope = CoroutineScope (SupervisorJob () + Dispatchers .Default )
@@ -12,7 +13,7 @@ object TestScope {
1213 }
1314}
1415
15- class Main {
16- val scope = TestScope
16+ object Main {
17+ val config = Config . ConfigData ()
1718
1819}
Original file line number Diff line number Diff line change 11package net.chariskar.breakthemod.apiTest ;
22
33import kotlinx.coroutines.runBlocking
4+ import net.chariskar.breakthemod.Main
45import net.chariskar.breakthemod.TestScope
56import net.chariskar.breakthemod.client.api.Fetch
67import net.chariskar.breakthemod.client.objects.StaffList
8+ import net.chariskar.breakthemod.client.utils.Config
79import org.junit.jupiter.api.Assertions
810import org.junit.jupiter.api.Test
911import kotlin.test.assertEquals
@@ -19,7 +21,7 @@ class EarthmcApiTest {
1921 @Test
2022 fun `test Get request` () {
2123 runBlocking {
22- val result = Fetch .getRequest<StaffList >(Fetch . Items . STAFF .url )
24+ val result = Fetch .getRequest<StaffList >(Main .config.staffRepoUrl )
2325 assertNotNull(result)
2426 assertIs<StaffList >(result)
2527 }
You can’t perform that action at this time.
0 commit comments