Remove nuxt + 100 other things..
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package utils
|
||||
|
||||
import org.skyscreamer.jsonassert.JSONAssert
|
||||
|
||||
infix fun String?.shouldBeEqualToJson(expected: String?) = JSONAssert.assertEquals(expected, this, false)
|
||||
|
||||
infix fun String?.`should be equal to json`(expected: String?) = shouldBeEqualToJson(expected)
|
||||
|
||||
infix fun String?.shouldStrictlyBeEqualToJson(expected: String?) = JSONAssert.assertEquals(expected, this, true)
|
||||
|
||||
infix fun String?.`should strictly be equal to json`(expected: String?) = shouldStrictlyBeEqualToJson(expected)
|
||||
|
||||
infix fun String?.shouldNotStrictlyBeEqualToJson(expected: String?) = JSONAssert.assertNotEquals(expected, this, true)
|
||||
|
||||
infix fun String?.`should not strictly be equal to json`(expected: String?) = shouldNotStrictlyBeEqualToJson(expected)
|
||||
|
||||
infix fun String?.shouldNotBeEqualToJson(expected: String?) = JSONAssert.assertNotEquals(expected, this, false)
|
||||
|
||||
infix fun String?.`should not be equal to json`(expected: String?) = shouldNotBeEqualToJson(expected)
|
||||
@@ -0,0 +1,23 @@
|
||||
package utils
|
||||
|
||||
import org.json.JSONObject
|
||||
|
||||
operator fun JSONObject.set(name: String, value: String) {
|
||||
this.put(name, value)
|
||||
}
|
||||
|
||||
operator fun JSONObject.set(name: String, value: Double) {
|
||||
this.put(name, value)
|
||||
}
|
||||
|
||||
operator fun JSONObject.set(name: String, value: Long) {
|
||||
this.put(name, value)
|
||||
}
|
||||
|
||||
operator fun JSONObject.set(name: String, value: Int) {
|
||||
this.put(name, value)
|
||||
}
|
||||
|
||||
operator fun JSONObject.set(name: String, value: Boolean) {
|
||||
this.put(name, value)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package utils
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig
|
||||
import com.zaxxer.hikari.HikariDataSource
|
||||
import org.testcontainers.containers.MariaDBContainer
|
||||
|
||||
class KMariadbContainer : MariaDBContainer<KMariadbContainer>() {
|
||||
fun datasource(): HikariDataSource {
|
||||
val hikariConfig = HikariConfig().apply {
|
||||
jdbcUrl = this@KMariadbContainer.jdbcUrl
|
||||
username = this@KMariadbContainer.username
|
||||
password = this@KMariadbContainer.password
|
||||
}
|
||||
|
||||
return HikariDataSource(hikariConfig)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package utils
|
||||
|
||||
import io.ktor.http.HttpHeaders
|
||||
import io.ktor.http.HttpMethod
|
||||
import io.ktor.server.testing.*
|
||||
import org.json.JSONObject
|
||||
|
||||
fun TestApplicationRequest.json(block: (JSONObject) -> Unit) {
|
||||
addHeader(HttpHeaders.ContentType, "application/json")
|
||||
setBody(JSONObject().apply(block).toString())
|
||||
}
|
||||
|
||||
fun TestApplicationRequest.setToken(token: String) {
|
||||
addHeader(HttpHeaders.Authorization, "Bearer $token")
|
||||
}
|
||||
|
||||
fun TestApplicationEngine.post(
|
||||
uri: String,
|
||||
setup: TestApplicationRequest.() -> Unit = {}
|
||||
): TestApplicationResponse = handleRequest {
|
||||
this.uri = uri
|
||||
this.method = HttpMethod.Post
|
||||
setup()
|
||||
}.response
|
||||
|
||||
fun TestApplicationEngine.get(
|
||||
uri: String,
|
||||
setup: TestApplicationRequest.() -> Unit = {}
|
||||
): TestApplicationResponse = handleRequest {
|
||||
this.uri = uri
|
||||
this.method = HttpMethod.Get
|
||||
setup()
|
||||
}.response
|
||||
|
||||
fun TestApplicationEngine.delete(
|
||||
uri: String,
|
||||
setup: TestApplicationRequest.() -> Unit = {}
|
||||
): TestApplicationResponse = handleRequest {
|
||||
this.uri = uri
|
||||
this.method = HttpMethod.Delete
|
||||
setup()
|
||||
}.response
|
||||
|
||||
fun TestApplicationEngine.put(
|
||||
uri: String,
|
||||
setup: TestApplicationRequest.() -> Unit = {}
|
||||
): TestApplicationResponse = handleRequest {
|
||||
this.uri = uri
|
||||
this.method = HttpMethod.Put
|
||||
setup()
|
||||
}.response
|
||||
@@ -0,0 +1,5 @@
|
||||
package utils
|
||||
|
||||
import org.json.JSONObject
|
||||
|
||||
fun JSONObject.keyList(): List<Any?> = keys().asSequence().toList()
|
||||
@@ -0,0 +1,6 @@
|
||||
package utils
|
||||
|
||||
import am.ik.yavi.core.ConstraintViolations
|
||||
|
||||
val ConstraintViolations.firstInvalid: Any?
|
||||
get() = this.violations().firstOrNull()?.name()
|
||||
Reference in New Issue
Block a user