Add operator test
This commit is contained in:
@@ -5,7 +5,6 @@ import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import kotlinx.coroutines.withTimeoutOrNull
|
||||
import com.shr4pnel.ferretirc.net.messages.ClientMessage as Message
|
||||
import org.junit.jupiter.api.AfterAll
|
||||
@@ -15,8 +14,6 @@ import java.io.File
|
||||
import java.lang.ProcessBuilder
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.time.Duration.Companion.microseconds
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
class IrcClientTest {
|
||||
@@ -52,7 +49,12 @@ class IrcClientTest {
|
||||
|
||||
@JvmStatic
|
||||
@AfterAll
|
||||
fun shutdown() = processes.forEach { it.destroy() }
|
||||
fun shutdown() = runBlocking {
|
||||
logger.info { "Closing server." }
|
||||
client.queueMessage(Message.Die())
|
||||
client.waitForNext<ServerMessage.Notice>()
|
||||
processes.forEach { it.destroy() }
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -74,5 +76,18 @@ class IrcClientTest {
|
||||
}
|
||||
assertNotNull(pong, "Reached timeout while waiting for PONG")
|
||||
assertEquals(token, pong.token, "Token in PING did not match PONG")
|
||||
logger.info { "Received PING" }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun oper() = runBlocking {
|
||||
client.queueMessage(Message.Oper("shr4p", "password"))
|
||||
val mode = withTimeoutOrNull(1.seconds) {
|
||||
client.waitForNext<ServerMessage.Mode>()
|
||||
}
|
||||
assertNotNull(mode, "Timed out waiting for OPER MODE response")
|
||||
assertEquals("shr4p", mode.operatorName, "Received incorrect operator name in MODE")
|
||||
assertEquals("+o", mode.pMask, "Received unexpected mask in MODE")
|
||||
logger.info { "Received MODE with mask ${mode.pMask}" }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user