Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Stexxe committed Oct 9, 2024
1 parent 089600c commit df056a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion chat/src/backendTest/kotlin/ChatApplicationTest.kt
Original file line number Diff line number Diff line change
@@ -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.*
Expand All @@ -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<String>()

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.*
Expand All @@ -15,6 +16,9 @@ class HttpBinApplicationTest {
@Test
fun testRedirect() {
testApplication {
environment {
config = ApplicationConfig(null)
}
val client = createClient {
followRedirects = false
}
Expand Down

0 comments on commit df056a0

Please sign in to comment.