From df056a0888b8ef682f09e8545e4eda0cc855c26b Mon Sep 17 00:00:00 2001 From: Aleksei Tirman Date: Wed, 9 Oct 2024 23:00:03 +0300 Subject: [PATCH] Fix tests --- chat/src/backendTest/kotlin/ChatApplicationTest.kt | 8 +++++++- .../io/ktor/samples/httpbin/HttpBinApplicationTest.kt | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/chat/src/backendTest/kotlin/ChatApplicationTest.kt b/chat/src/backendTest/kotlin/ChatApplicationTest.kt index b36c658d..1349e995 100644 --- a/chat/src/backendTest/kotlin/ChatApplicationTest.kt +++ b/chat/src/backendTest/kotlin/ChatApplicationTest.kt @@ -1,7 +1,7 @@ package io.ktor.samples.chat.backend import io.ktor.client.plugins.websocket.* -import io.ktor.server.application.* +import io.ktor.server.config.ApplicationConfig import io.ktor.server.testing.* import io.ktor.websocket.* import kotlin.test.* @@ -18,6 +18,9 @@ class ChatApplicationTest { // First, we create a [TestApplicationEngine] that includes the module [Application.main], // this executes that function and thus installs all the plugins and routes to this test application. testApplication { + environment { + config = ApplicationConfig(null) + } // Keeps a log array that will hold all the events we want to check later at once. val log = arrayListOf() @@ -57,6 +60,9 @@ class ChatApplicationTest { fun testDualConversation() { // Creates the [TestApplicationEngine] with the [Application::main] module. Check the previous test for more details. testApplication { + environment { + config = ApplicationConfig(null) + } // Sets to hold the messages from each children. // Since this is multithreaded and socket-related. // The order might change in each run, so we use a Set instead of a List to check that the messages diff --git a/httpbin/src/test/kotlin/io/ktor/samples/httpbin/HttpBinApplicationTest.kt b/httpbin/src/test/kotlin/io/ktor/samples/httpbin/HttpBinApplicationTest.kt index 09c7bcfa..788d9994 100644 --- a/httpbin/src/test/kotlin/io/ktor/samples/httpbin/HttpBinApplicationTest.kt +++ b/httpbin/src/test/kotlin/io/ktor/samples/httpbin/HttpBinApplicationTest.kt @@ -1,6 +1,7 @@ package io.ktor.samples.httpbin import io.ktor.client.request.* +import io.ktor.server.config.ApplicationConfig import io.ktor.server.testing.* import org.junit.Test import kotlin.test.* @@ -15,6 +16,9 @@ class HttpBinApplicationTest { @Test fun testRedirect() { testApplication { + environment { + config = ApplicationConfig(null) + } val client = createClient { followRedirects = false }