Skip to content

Commit

Permalink
fix/integration test dependency (#957)
Browse files Browse the repository at this point in the history
* Specify fasterxml jackson core version for Google cloud bom libraries

* Include rationale

* Adjust comment format
  • Loading branch information
ashdavies authored Apr 28, 2024
1 parent 1f1791a commit 4651ba6
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
8 changes: 8 additions & 0 deletions cloud-run/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ kotlin {
implementation(libs.ktor.server.test.host)
}

jvmMain.dependencies {
compileOnly(libs.fasterxml.jackson.core)?.because(
"runtimeClasspath configuration transitively depends upon jackson-databind" +
" 2.17.0, but 2.14.2 is required by compileClasspath dependencies, this " +
"causes exceptions due to missing method errors at runtime.",
)
}

val jvmIntegrationTest by getting {
dependencies {
implementation(kotlin("test-junit"))
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion cloud-run/src/commonMain/kotlin/io/ashdavies/cloud/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public fun main() {
server.start(wait = true)
}

internal fun Application.main(client: HttpClient = defaultHttpClient()) {
internal fun Application.main(client: HttpClient = defaultHttpClient { installCallValidator() }) {
install(DefaultHeaders, DefaultHeadersConfig::headers)
install(Compression, CompressionConfig::default)
install(ContentNegotiation, Configuration::json)
Expand Down
30 changes: 30 additions & 0 deletions cloud-run/src/commonMain/kotlin/io/ashdavies/cloud/Validator.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.ashdavies.cloud

import io.ktor.client.HttpClientConfig
import io.ktor.client.call.body
import io.ktor.client.plugins.ClientRequestException
import io.ktor.client.plugins.HttpCallValidator
import kotlinx.serialization.Serializable

internal fun HttpClientConfig<*>.installCallValidator() {
install(HttpCallValidator) {
handleResponseExceptionWithRequest { exception, _ ->
if (exception is ClientRequestException) {
throw exception.response.body<GoogleApisException>()
}
}
}

expectSuccess = true
}

@Serializable
internal data class GoogleApisException(val error: Error) : Exception(error.message) {

@Serializable
data class Error(
val code: Int,
val message: String,
val status: String,
)
}
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ coil-network = { module = "io.coil-kt.coil3:coil-network-ktor", version.ref = "c
compose-compiler = { module = "org.jetbrains.compose.compiler:compiler", version.ref = "compose-compiler" }
compose-runtime = { module = "org.jetbrains.compose.runtime:runtime", version.ref = "jetbrains-compose" }

fasterxml-jackson-core = "com.fasterxml.jackson.core:jackson-core:2.17.0"
fusesource-jansi = "org.fusesource.jansi:jansi:2.4.1"

gitlive-firebase-app = { module = "dev.gitlive:firebase-app", version.ref = "gitlive-firebase" }
Expand Down

0 comments on commit 4651ba6

Please sign in to comment.