Skip to content

Commit

Permalink
add integration tests for kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmossas committed Nov 22, 2024
1 parent ad6542b commit c5171e2
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion tests/clients/kotlin/src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import io.ktor.client.plugins.*
import kotlinx.coroutines.*
import kotlinx.serialization.json.JsonPrimitive
import java.time.Instant
import java.util.*

fun main() {
val httpClient = HttpClient() {
Expand Down Expand Up @@ -84,6 +85,35 @@ fun main() {
expect(tag, result.string, "hello world")
}

runBlocking {
val tag = "SEND/RECEIVE OBJECT WITH SNAKE_CASE KEYS"
val input = ObjectWithSnakeCaseKeys(
createdAt = targetDate,
displayName = "john doe",
phoneNumber = null,
emailAddress = "[email protected]",
isAdmin = null
)
val result = client.tests.sendObjectWithSnakeCaseKeys(input)
expect(tag, result, input)
}

runBlocking {
val tag = "SEND/RECEIVE OBJECT WITH PASCAL CASE KEYS"
var input = ObjectWithPascalCaseKeys(
createdAt = targetDate,
displayName = "john doe",
phoneNumber = "211-211-2111",
emailAddress = null,
isAdmin = true
)
val result = client.tests.sendObjectWithPascalCaseKeys(input)
expect(tag, result, input)
input = input.copy(isAdmin = null)
val result2 = client.tests.sendObjectWithPascalCaseKeys(input)
expect(tag, result2, input)
}

runBlocking {
val tag = "UNAUTHENTICATED REQUEST RETURNS ERROR"
try {
Expand Down Expand Up @@ -434,7 +464,7 @@ fun testSseReconnectsWithNewCredentials(httpClient: HttpClient, baseUrl: String)
httpClient = httpClient,
baseUrl = baseUrl,
headers = {
val newHeader = "kt_${java.util.UUID.randomUUID().toString()}"
val newHeader = "kt_${UUID.randomUUID().toString()}"
headers.add(newHeader)
mutableMapOf(Pair("x-test-header", newHeader))
}
Expand Down

0 comments on commit c5171e2

Please sign in to comment.