Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Ktor to 3.0.3 #2066

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

timemanx
Copy link

📝 Description

Updated Ktor and updated failing tests and fixed compile issues resulting from the update.
Also updated some libraries.

🔗 Related Issues

#2037

@timemanx timemanx mentioned this pull request Dec 21, 2024
every { application } returns mockk(relaxed = true) {
every { receivePipeline } returns ApplicationReceivePipeline()
}
coEvery { receiveNullable<Any>(any()) } answers { callOriginal() }
Copy link
Author

@timemanx timemanx Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

receiveNullable() (which is called from ApplicationCall.receive() in KtorGraphQLRequestParser.parsePostRequest()) is now an instance method instead of an extension function which is why ApplicationCall.receive() returns null when using a mock.
Using callOriginal() calls the instance method instead.

In Ktor 2.3.12
https://github.com/ktorio/ktor/blob/2.3.12/ktor-server/ktor-server-core/jvmAndNix/src/io/ktor/server/request/ApplicationReceiveFunctions.kt#L95

In Ktor 3.0.x
https://github.com/ktorio/ktor/blob/main/ktor-server/ktor-server-core/common/src/io/ktor/server/application/PipelineCall.kt#L84

@@ -31,11 +31,11 @@ class CustomScalarKotlinxTests {

@Test
fun `verify custom scalars are correctly serialized and deserialized`() {
val engine = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
val embeddedServer = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

embeddedServer() now returns an EmbeddedServer which contains the ApplicationEngine.
https://ktor.io/docs/migrating-3.html#EmbeddedServer


fun Application.graphQLModule() {
install(WebSockets) {
pingPeriod = Duration.ofSeconds(1)
pingPeriod = 1.seconds
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Websockets plugin now uses kotlin.time.
https://youtrack.jetbrains.com/issue/KTOR-7446


private fun testModule(block: suspend io.ktor.server.testing.ApplicationTestBuilder.() -> kotlin.Unit) = testApplication {
environment {
config = ApplicationConfig(("application.conf"))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modules need to be explicitly loaded.
https://ktor.io/docs/migrating-3.html#test-module-loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants