39 lines
1.6 KiB
Kotlin
39 lines
1.6 KiB
Kotlin
package com.shr4pnel.ferretirc
|
|
|
|
import io.github.oshai.kotlinlogging.KotlinLogging
|
|
import kotlinx.coroutines.runBlocking
|
|
import org.junit.jupiter.api.BeforeAll
|
|
import java.io.File
|
|
|
|
class IRCErrTest {
|
|
companion object {
|
|
lateinit var processes: MutableList<Process>
|
|
val client = IrcClient("localhost", 6667, enableLogging = true)
|
|
private val logger = KotlinLogging.logger {}
|
|
|
|
@JvmStatic
|
|
@BeforeAll
|
|
fun setup(): Unit =
|
|
runBlocking {
|
|
val logFile = File("src/test/resources/logs/ngircd.log")
|
|
val ngircdConfigPath = javaClass.classLoader.getResource("ngircd.conf")!!.path
|
|
logFile.createNewFile()
|
|
processes =
|
|
ProcessBuilder.startPipeline(
|
|
listOf<ProcessBuilder>(
|
|
// Run IRC server in [-d] debug log mode, with [-n] no daemon, using config [-f] file at path
|
|
ProcessBuilder("ngircd", "-dnf", ngircdConfigPath).redirectErrorStream(true),
|
|
// Remove unhelpful default ngircd info [PID. relative time, GID?]
|
|
ProcessBuilder("sed", "-ue", "s/\\[[^][]*\\]//g"),
|
|
// Add relative timestamp
|
|
ProcessBuilder("ts", "-s", "%H:%M:%.S").redirectOutput(logFile),
|
|
),
|
|
)
|
|
client.connect()
|
|
client.register("shr4p", "Tyler Fullname", "password")
|
|
val default = client.server.fetchChannels().first()
|
|
client.join(default)
|
|
}
|
|
}
|
|
}
|