anonircd/entity_test.go

31 lines
842 B
Go

package main
import (
"reflect"
"testing"
)
func TestEntityMode(t *testing.T) {
channel := NewChannel("#channel")
channel.addModes([]string{"pk", "MyAwesomeChannelKey"})
modes := channel.getModes()
if !reflect.DeepEqual(modes, map[string]string{"k": "MyAwesomeChannelKey", "p": ""}) {
t.Fatalf("unexpected modes: %s", modes)
}
if channel.printModes(modes, nil) != "+kp" {
t.Fatalf("unexpected printModes: %s", channel.printModes(modes, nil))
}
client := NewClient("client", nil, false)
client.addModes([]string{"ck", "MyAwesomeChannelKey"}) // +k is not a client mode
modes = client.getModes()
if !reflect.DeepEqual(modes, map[string]string{"c": ""}) {
t.Fatalf("unexpected modes: %s", modes)
}
if channel.printModes(modes, nil) != "+c" {
t.Fatalf("unexpected printModes: %s", channel.printModes(modes, nil))
}
}