ketracel/spec/ngircd_harness_spec.moon

88 lines
2.4 KiB
Plaintext

irce = require "irce"
socket = require "socket"
test = require "ketracel.test"
Server = require("ketracel.server").Server
uuid = require "uuid"
ln = require "ln"
describe "ngircd protocol support", ->
local server
local client
setup ->
file = io.popen "ngircd -n -f ./spec/ngircd.conf", "r"
server = Server
server: "127.0.0.1"
sname: "ketracel.akua"
spass: "hunter2"
sreal: "Ketracel"
nicklen: "31"
debug: os.getenv "DEBUG"
client = test.Client "test_user"
teardown ->
with io.popen "killall ngircd", "r"
\close!
it "actually is running ngircd", ->
with io.popen "pstree"
data = \read "*all"
assert.truthy string.find data, "ngircd"
it "sees end of burst", ->
server\wait_for "376"
it "can use the Client class", ->
client\wait_for "005"
it "sees the client", ->
server\wait_for "NICK", (source, user) ->
user.nick == "test_user"
local channame
it "sees the client join a new channel", ->
channame = uuid()
client.irc\JOIN "#" .. channame
server\wait_for "JOIN", (who, chan) ->
chan.name == "#" .. channame
client\wait_for "JOIN", (sender, channel) ->
channel\sub(2) == channame
it "sees the client part the channel", ->
client.irc\PART "#" .. channame
server\wait_for "PART", (who, chan) ->
chan.name == "#" .. channame
it "sees nickchanges", ->
client.irc\send_raw "NICK newnick"
server\wait_for "NICKCHG", (sender, clinfo) ->
clinfo.nick == "newnick"
it "sees quits", ->
cli = test.Client "quitter"
cli\wait_for "005"
cli.irc\QUIT "bye"
server\wait_for "QUIT", (sender, msg) ->
sender == "quitter"
it "sees a privmsg", ->
client.irc\JOIN "#ketracel"
client.irc\PRIVMSG "#ketracel", "hi"
server\wait_for "PRIVMSG", (sender, params) ->
params[1] == "#ketracel" and params[2] == "hi"
describe "ketracel bot", ->
it "has a working VHOST command", ->
client.irc\PRIVMSG "Ketracel", "VHOST my.cool.vhost"
server\wait_for "PRIVMSG", (sender, params) ->
params[1] == "Ketracel" and params[2] == "VHOST my.cool.vhost"
client\wait_for "396"
client\wait_for "NOTICE", (sender, origin, message, pm) ->
message\find "my.cool.vhost"
it "replies to unknown commands", ->
client.irc\PRIVMSG "KETRACEL", uuid()
server\wait_for "PRIVMSG"
client\wait_for "NOTICE"