Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

Viewing file on branch master

1package samechannel
2
3import (
4 "io"
5 "testing"
6
7 "github.com/matterbridge-org/matterbridge/bridge/config"
8 "github.com/sirupsen/logrus"
9 "github.com/stretchr/testify/assert"
10)
11
12const testConfig = `
13[mattermost.test]
14[slack.test]
15
16[[samechannelgateway]]
17 enable = true
18 name = "blah"
19 accounts = [ "mattermost.test","slack.test" ]
20 channels = [ "testing","testing2","testing10"]
21`
22
23var (
24 expectedConfig = config.Gateway{
25 Name: "blah",
26 Enable: true,
27 In: []config.Bridge(nil),
28 Out: []config.Bridge(nil),
29 InOut: []config.Bridge{
30 {
31 Account: "mattermost.test",
32 Channel: "testing",
33 Options: config.ChannelOptions{Key: ""},
34 SameChannel: true,
35 },
36 {
37 Account: "mattermost.test",
38 Channel: "testing2",
39 Options: config.ChannelOptions{Key: ""},
40 SameChannel: true,
41 },
42 {
43 Account: "mattermost.test",
44 Channel: "testing10",
45 Options: config.ChannelOptions{Key: ""},
46 SameChannel: true,
47 },
48 {
49 Account: "slack.test",
50 Channel: "testing",
51 Options: config.ChannelOptions{Key: ""},
52 SameChannel: true,
53 },
54 {
55 Account: "slack.test",
56 Channel: "testing2",
57 Options: config.ChannelOptions{Key: ""},
58 SameChannel: true,
59 },
60 {
61 Account: "slack.test",
62 Channel: "testing10",
63 Options: config.ChannelOptions{Key: ""},
64 SameChannel: true,
65 },
66 },
67 }
68)
69
70func TestGetConfig(t *testing.T) {
71 logger := logrus.New()
72 logger.SetOutput(io.Discard)
73 cfg := config.NewConfigFromString(logger, []byte(testConfig))
74 sgw := New(cfg)
75 configs := sgw.GetConfig()
76 assert.Equal(t, []config.Gateway{expectedConfig}, configs)
77}
78