mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
add a test
This commit is contained in:
parent
1016f86f70
commit
7122fb180c
@ -8,6 +8,47 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseChannelModeChanges(t *testing.T) {
|
||||
modes, unknown := ParseChannelModeChanges("+h", "wrmsr")
|
||||
if len(unknown) > 0 {
|
||||
t.Errorf("unexpected unknown mode change: %v", unknown)
|
||||
}
|
||||
expected := ModeChange{
|
||||
Op: Add,
|
||||
Mode: Halfop,
|
||||
Arg: "wrmsr",
|
||||
}
|
||||
if len(modes) != 1 || modes[0] != expected {
|
||||
t.Errorf("unexpected mode change: %v", modes)
|
||||
}
|
||||
|
||||
modes, unknown = ParseChannelModeChanges("-v", "shivaram")
|
||||
if len(unknown) > 0 {
|
||||
t.Errorf("unexpected unknown mode change: %v", unknown)
|
||||
}
|
||||
expected = ModeChange{
|
||||
Op: Remove,
|
||||
Mode: Voice,
|
||||
Arg: "shivaram",
|
||||
}
|
||||
if len(modes) != 1 || modes[0] != expected {
|
||||
t.Errorf("unexpected mode change: %v", modes)
|
||||
}
|
||||
|
||||
modes, unknown = ParseChannelModeChanges("+tx")
|
||||
if len(unknown) != 1 || !unknown['x'] {
|
||||
t.Errorf("expected that x is an unknown mode, instead: %v", unknown)
|
||||
}
|
||||
expected = ModeChange{
|
||||
Op: Add,
|
||||
Mode: OpOnlyTopic,
|
||||
Arg: "",
|
||||
}
|
||||
if len(modes) != 1 || modes[0] != expected {
|
||||
t.Errorf("unexpected mode change: %v", modes)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetMode(t *testing.T) {
|
||||
set := NewModeSet()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user