Anonymous IRC daemon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
842 B

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))
}
}