anonircd/entity_test.go

31 lines
842 B
Go
Raw Normal View History

2019-03-29 01:53:17 +00:00
package main
import (
2021-06-25 05:47:18 +00:00
"reflect"
2019-03-29 01:53:17 +00:00
"testing"
)
func TestEntityMode(t *testing.T) {
channel := NewChannel("#channel")
channel.addModes([]string{"pk", "MyAwesomeChannelKey"})
modes := channel.getModes()
2021-06-25 05:47:18 +00:00
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))
}
2019-03-29 01:53:17 +00:00
client := NewClient("client", nil, false)
client.addModes([]string{"ck", "MyAwesomeChannelKey"}) // +k is not a client mode
modes = client.getModes()
2021-06-25 05:47:18 +00:00
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))
}
2019-03-29 01:53:17 +00:00
}