3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 18:52:41 +01:00

add a test

This commit is contained in:
Shivaram Lingamneni 2018-05-23 16:14:23 -04:00
parent 1016f86f70
commit 7122fb180c

View File

@ -8,6 +8,47 @@ import (
"testing" "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) { func TestSetMode(t *testing.T) {
set := NewModeSet() set := NewModeSet()