summaryrefslogtreecommitdiffstats
path: root/gateway/gateway_test.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-02-23 22:51:27 +0100
committerGitHub <noreply@github.com>2019-02-23 22:51:27 +0100
commitbf21604d425b4feb1b95e4e94643e7a658eeea90 (patch)
tree376741188b9646ef66526b36e24d3577f07a678f /gateway/gateway_test.go
parent1bb39eba8717f62336cc98c5bb7cfbef194f3626 (diff)
downloadmatterbridge-msglm-bf21604d425b4feb1b95e4e94643e7a658eeea90.tar.gz
matterbridge-msglm-bf21604d425b4feb1b95e4e94643e7a658eeea90.tar.bz2
matterbridge-msglm-bf21604d425b4feb1b95e4e94643e7a658eeea90.zip
Make all loggers derive from non-default instance (#728)
Diffstat (limited to 'gateway/gateway_test.go')
-rw-r--r--gateway/gateway_test.go46
1 files changed, 32 insertions, 14 deletions
diff --git a/gateway/gateway_test.go b/gateway/gateway_test.go
index 677afde4..b9bb5b93 100644
--- a/gateway/gateway_test.go
+++ b/gateway/gateway_test.go
@@ -2,12 +2,15 @@ package gateway
import (
"fmt"
+ "io/ioutil"
"strconv"
"testing"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/gateway/bridgemap"
+ "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/suite"
)
var testconfig = []byte(`
@@ -159,8 +162,10 @@ const (
)
func maketestRouter(input []byte) *Router {
- cfg := config.NewConfigFromString(input)
- r, err := NewRouter(cfg, bridgemap.FullMap)
+ logger := logrus.New()
+ logger.SetOutput(ioutil.Discard)
+ cfg := config.NewConfigFromString(logger, input)
+ r, err := NewRouter(logger, cfg, bridgemap.FullMap)
if err != nil {
fmt.Println(err)
}
@@ -387,7 +392,23 @@ func TestGetDestChannelAdvanced(t *testing.T) {
assert.Equal(t, map[string]int{"bridge3": 4, "bridge": 9, "announcements": 3, "bridge2": 4}, hits)
}
-func TestIgnoreTextEmpty(t *testing.T) {
+type ignoreTestSuite struct {
+ suite.Suite
+
+ gw *Gateway
+}
+
+func TestIgnoreSuite(t *testing.T) {
+ s := &ignoreTestSuite{}
+ suite.Run(t, s)
+}
+
+func (s *ignoreTestSuite) SetupSuite() {
+ logger := logrus.New()
+ logger.SetOutput(ioutil.Discard)
+ s.gw = &Gateway{logger: logrus.NewEntry(logger)}
+}
+func (s *ignoreTestSuite) TestIgnoreTextEmpty() {
extraFile := make(map[string][]interface{})
extraAttach := make(map[string][]interface{})
extraFailure := make(map[string][]interface{})
@@ -424,15 +445,14 @@ func TestIgnoreTextEmpty(t *testing.T) {
output: true,
},
}
- gw := &Gateway{}
for testname, testcase := range msgTests {
- output := gw.ignoreTextEmpty(testcase.input)
- assert.Equalf(t, testcase.output, output, "case '%s' failed", testname)
+ output := s.gw.ignoreTextEmpty(testcase.input)
+ s.Assert().Equalf(testcase.output, output, "case '%s' failed", testname)
}
}
-func TestIgnoreTexts(t *testing.T) {
+func (s *ignoreTestSuite) TestIgnoreTexts() {
msgTests := map[string]struct {
input string
re []string
@@ -459,14 +479,13 @@ func TestIgnoreTexts(t *testing.T) {
output: true,
},
}
- gw := &Gateway{}
for testname, testcase := range msgTests {
- output := gw.ignoreText(testcase.input, testcase.re)
- assert.Equalf(t, testcase.output, output, "case '%s' failed", testname)
+ output := s.gw.ignoreText(testcase.input, testcase.re)
+ s.Assert().Equalf(testcase.output, output, "case '%s' failed", testname)
}
}
-func TestIgnoreNicks(t *testing.T) {
+func (s *ignoreTestSuite) TestIgnoreNicks() {
msgTests := map[string]struct {
input string
re []string
@@ -493,10 +512,9 @@ func TestIgnoreNicks(t *testing.T) {
output: false,
},
}
- gw := &Gateway{}
for testname, testcase := range msgTests {
- output := gw.ignoreText(testcase.input, testcase.re)
- assert.Equalf(t, testcase.output, output, "case '%s' failed", testname)
+ output := s.gw.ignoreText(testcase.input, testcase.re)
+ s.Assert().Equalf(testcase.output, output, "case '%s' failed", testname)
}
}