summaryrefslogtreecommitdiffstats
path: root/gateway/gateway_test.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-02-17 21:49:28 +0100
committerGitHub <noreply@github.com>2019-02-17 21:49:28 +0100
commit4525fa31aa6ea595c93994b05a3a042965249100 (patch)
tree93a167d0ca7db839a32356968019faae2d04e134 /gateway/gateway_test.go
parentaeaea0574f491e61d90b2ce318c1ac26ddba2be1 (diff)
downloadmatterbridge-msglm-4525fa31aa6ea595c93994b05a3a042965249100.tar.gz
matterbridge-msglm-4525fa31aa6ea595c93994b05a3a042965249100.tar.bz2
matterbridge-msglm-4525fa31aa6ea595c93994b05a3a042965249100.zip
Allow regexs in ignoreNicks. Closes #690 (#720)
Diffstat (limited to 'gateway/gateway_test.go')
-rw-r--r--gateway/gateway_test.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/gateway/gateway_test.go b/gateway/gateway_test.go
index cd78fe99..9621ab7d 100644
--- a/gateway/gateway_test.go
+++ b/gateway/gateway_test.go
@@ -434,68 +434,68 @@ func TestIgnoreTextEmpty(t *testing.T) {
func TestIgnoreTexts(t *testing.T) {
msgTests := map[string]struct {
- input *config.Message
+ input string
re []string
output bool
}{
"no regex": {
- input: &config.Message{Text: "a text message"},
+ input: "a text message",
re: []string{},
output: false,
},
"simple regex": {
- input: &config.Message{Text: "a text message"},
+ input: "a text message",
re: []string{"text"},
output: true,
},
"multiple regex fail": {
- input: &config.Message{Text: "a text message"},
+ input: "a text message",
re: []string{"abc", "123$"},
output: false,
},
"multiple regex pass": {
- input: &config.Message{Text: "a text message"},
+ input: "a text message",
re: []string{"lala", "sage$"},
output: true,
},
}
gw := &Gateway{}
for testname, testcase := range msgTests {
- output := gw.ignoreTexts(testcase.input, testcase.re)
+ output := gw.ignoreText(testcase.input, testcase.re)
assert.Equalf(t, testcase.output, output, "case '%s' failed", testname)
}
}
func TestIgnoreNicks(t *testing.T) {
msgTests := map[string]struct {
- input *config.Message
+ input string
re []string
output bool
}{
"no entry": {
- input: &config.Message{Username: "user", Text: "a text message"},
+ input: "user",
re: []string{},
output: false,
},
"one entry": {
- input: &config.Message{Username: "user", Text: "a text message"},
+ input: "user",
re: []string{"user"},
output: true,
},
"multiple entries": {
- input: &config.Message{Username: "user", Text: "a text message"},
+ input: "user",
re: []string{"abc", "user"},
output: true,
},
"multiple entries fail": {
- input: &config.Message{Username: "user", Text: "a text message"},
+ input: "user",
re: []string{"abc", "def"},
output: false,
},
}
gw := &Gateway{}
for testname, testcase := range msgTests {
- output := gw.ignoreNicks(testcase.input, testcase.re)
+ output := gw.ignoreText(testcase.input, testcase.re)
assert.Equalf(t, testcase.output, output, "case '%s' failed", testname)
}
}