[O] Separate common functions for tests

This commit is contained in:
Azalea
2024-03-27 22:39:27 -04:00
parent e14a131480
commit ad13875137
2 changed files with 22 additions and 26 deletions

View File

@@ -0,0 +1,20 @@
package ext
import kotlin.random.Random
import kotlin.random.nextInt
const val CLIENT_ID = "A1234567890"
const val FTK = "test"
const val HOST = "http://localhost"
val ACCESS_CODE = "9900" + (1..16).map { Random.nextInt(0..9) }.joinToString("")
inline fun <reified T> String.json() = try {
JACKSON.readValue(this, T::class.java)
}
catch (e: Exception) {
println("Failed to parse JSON: $this")
throw e
}
fun String.jsonMap(): Map<String, Any?> = json()
fun String.jsonArray(): List<Map<String, Any?>> = json()