mirror of
https://github.com/fluffle/goirc
synced 2025-05-14 03:23:21 +00:00
Remove Commands from core goirc.
This dictates too much about how people might want to parse and act upon information from PRIVMSGs, and thus should be an optional thing.
This commit is contained in:
parent
7bb84985ee
commit
4cd3831e92
5 changed files with 1 additions and 241 deletions
|
@ -176,54 +176,3 @@ func TestHandlerSet(t *testing.T) {
|
|||
t.Errorf("Our handler was called?")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommandSet(t *testing.T) {
|
||||
cs := commandSet()
|
||||
if len(cs.set) != 0 {
|
||||
t.Errorf("New set contains things!")
|
||||
}
|
||||
|
||||
c := &command{
|
||||
fn: func(c *Conn, l *Line) {},
|
||||
help: "wtf?",
|
||||
}
|
||||
|
||||
cn1 := cs.add("ONE", c).(*cNode)
|
||||
if _, ok := cs.set["one"]; !ok || cn1.set != cs || cn1.prefix != "one" {
|
||||
t.Errorf("Command 'one' not added to set correctly.")
|
||||
}
|
||||
|
||||
if fail := cs.add("one", c); fail != nil {
|
||||
t.Errorf("Adding a second 'one' command did not fail as expected.")
|
||||
}
|
||||
|
||||
cn2 := cs.add("One Two", c).(*cNode)
|
||||
if _, ok := cs.set["one two"]; !ok || cn2.set != cs || cn2.prefix != "one two" {
|
||||
t.Errorf("Command 'one two' not added to set correctly.")
|
||||
}
|
||||
|
||||
if c, l := cs.match("foo"); c != nil || l != 0 {
|
||||
t.Errorf("Matched 'foo' when we shouldn't.")
|
||||
}
|
||||
if c, l := cs.match("one"); c.(*cNode) != cn1 || l != 3 {
|
||||
t.Errorf("Didn't match 'one' when we should have.")
|
||||
}
|
||||
if c, l := cs.match("one two three"); c.(*cNode) != cn2 || l != 7 {
|
||||
t.Errorf("Didn't match 'one two' when we should have.")
|
||||
}
|
||||
|
||||
cs.remove(cn2)
|
||||
if _, ok := cs.set["one two"]; ok || cn2.set != nil {
|
||||
t.Errorf("Command 'one two' not removed correctly.")
|
||||
}
|
||||
if c, l := cs.match("one two three"); c.(*cNode) != cn1 || l != 3 {
|
||||
t.Errorf("Didn't match 'one' when we should have.")
|
||||
}
|
||||
cn1.Remove()
|
||||
if _, ok := cs.set["one"]; ok || cn1.set != nil {
|
||||
t.Errorf("Command 'one' not removed correctly.")
|
||||
}
|
||||
if c, l := cs.match("one two three"); c != nil || l != 0 {
|
||||
t.Errorf("Matched 'one' when we shouldn't have.")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue