summaryrefslogtreecommitdiffstats
path: root/gateway/samechannel/samechannel_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'gateway/samechannel/samechannel_test.go')
-rw-r--r--gateway/samechannel/samechannel_test.go59
1 files changed, 50 insertions, 9 deletions
diff --git a/gateway/samechannel/samechannel_test.go b/gateway/samechannel/samechannel_test.go
index 7c75444f..c0e579ae 100644
--- a/gateway/samechannel/samechannel_test.go
+++ b/gateway/samechannel/samechannel_test.go
@@ -1,16 +1,13 @@
package samechannelgateway
import (
- "fmt"
-
"github.com/42wim/matterbridge/bridge/config"
- "github.com/BurntSushi/toml"
"github.com/stretchr/testify/assert"
"testing"
)
-var testconfig = `
+const testConfig = `
[mattermost.test]
[slack.test]
@@ -21,12 +18,56 @@ var testconfig = `
channels = [ "testing","testing2","testing10"]
`
-func TestGetConfig(t *testing.T) {
- var cfg *config.Config
- if _, err := toml.Decode(testconfig, &cfg); err != nil {
- fmt.Println(err)
+var (
+ expectedConfig = config.Gateway{
+ Name: "blah",
+ Enable: true,
+ In: []config.Bridge(nil),
+ Out: []config.Bridge(nil),
+ InOut: []config.Bridge{
+ {
+ Account: "mattermost.test",
+ Channel: "testing",
+ Options: config.ChannelOptions{Key: ""},
+ SameChannel: true,
+ },
+ {
+ Account: "mattermost.test",
+ Channel: "testing2",
+ Options: config.ChannelOptions{Key: ""},
+ SameChannel: true,
+ },
+ {
+ Account: "mattermost.test",
+ Channel: "testing10",
+ Options: config.ChannelOptions{Key: ""},
+ SameChannel: true,
+ },
+ {
+ Account: "slack.test",
+ Channel: "testing",
+ Options: config.ChannelOptions{Key: ""},
+ SameChannel: true,
+ },
+ {
+ Account: "slack.test",
+ Channel: "testing2",
+ Options: config.ChannelOptions{Key: ""},
+ SameChannel: true,
+ },
+ {
+ Account: "slack.test",
+ Channel: "testing10",
+ Options: config.ChannelOptions{Key: ""},
+ SameChannel: true,
+ },
+ },
}
+)
+
+func TestGetConfig(t *testing.T) {
+ cfg := config.NewConfigFromString([]byte(testConfig))
sgw := New(cfg)
configs := sgw.GetConfig()
- assert.Equal(t, []config.Gateway{{Name: "blah", Enable: true, In: []config.Bridge(nil), Out: []config.Bridge(nil), InOut: []config.Bridge{{Account: "mattermost.test", Channel: "testing", Options: config.ChannelOptions{Key: ""}, SameChannel: true}, {Account: "mattermost.test", Channel: "testing2", Options: config.ChannelOptions{Key: ""}, SameChannel: true}, {Account: "mattermost.test", Channel: "testing10", Options: config.ChannelOptions{Key: ""}, SameChannel: true}, {Account: "slack.test", Channel: "testing", Options: config.ChannelOptions{Key: ""}, SameChannel: true}, {Account: "slack.test", Channel: "testing2", Options: config.ChannelOptions{Key: ""}, SameChannel: true}, {Account: "slack.test", Channel: "testing10", Options: config.ChannelOptions{Key: ""}, SameChannel: true}}}}, configs)
+ assert.Equal(t, []config.Gateway{expectedConfig}, configs)
}