Initial commit

This commit is contained in:
2026-08-06 01:03:27 +01:00
commit aa74300efb
20 changed files with 685 additions and 0 deletions
@@ -0,0 +1,52 @@
package com.shr4pnel.ferretirc
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import com.shr4pnel.ferretirc.net.ClientMessage as Msg
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
import java.io.File
import java.lang.ProcessBuilder
import java.net.URI
class IrcClientTest {
companion object {
lateinit var proc: Process
@JvmStatic
@BeforeAll
fun setup() {
val logFile = File("src/test/resources/logs/ngircd.log")
logFile.createNewFile()
proc = ProcessBuilder("ngircd", "-nd")
.redirectOutput(logFile)
.redirectErrorStream(true)
.start()
}
@JvmStatic
@AfterAll
fun shutdown() {
proc.destroy()
}
}
@Test
fun sample() {
val client = IrcClient("shrpnl", URI("http://localhost:6667").toURL())
client.scope.launch {
client.connect()
client.queueMessage(Msg.Cap.LS(302))
delay(1000)
client.scope.launch {
for (msg in client.messages)
println(msg)
}
delay(1000)
client.close()
}
runBlocking { delay(1500) }
}
}