mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
add a test for default channel mode parsing
This commit is contained in:
parent
333afe1062
commit
6063d30bc5
36
irc/modes_test.go
Normal file
36
irc/modes_test.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
// Copyright (c) 2017 Daniel Oaks
|
||||||
|
// released under the MIT license
|
||||||
|
|
||||||
|
package irc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestParseDefaultChannelModes(t *testing.T) {
|
||||||
|
nt := "+nt"
|
||||||
|
n := "+n"
|
||||||
|
empty := ""
|
||||||
|
tminusi := "+t -i"
|
||||||
|
|
||||||
|
var parseTests = []struct {
|
||||||
|
raw *string
|
||||||
|
expected Modes
|
||||||
|
}{
|
||||||
|
{&nt, Modes{NoOutside, OpOnlyTopic}},
|
||||||
|
{&n, Modes{NoOutside}},
|
||||||
|
{&empty, Modes{}},
|
||||||
|
{&tminusi, Modes{OpOnlyTopic}},
|
||||||
|
{nil, Modes{NoOutside, OpOnlyTopic}},
|
||||||
|
}
|
||||||
|
|
||||||
|
var config Config
|
||||||
|
for _, testcase := range parseTests {
|
||||||
|
config.Channels.DefaultModes = testcase.raw
|
||||||
|
result := ParseDefaultChannelModes(&config)
|
||||||
|
if !reflect.DeepEqual(result, testcase.expected) {
|
||||||
|
t.Errorf("expected modes %s, got %s", testcase.expected, result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user