diff options
author | Patrick Connolly <patrick.c.connolly@gmail.com> | 2018-11-26 17:47:04 +0800 |
---|---|---|
committer | Duco van Amstel <duco.vanamstel@gmail.com> | 2018-11-26 09:47:04 +0000 |
commit | f5659d455d2c28a6f2fe4c40f4dc344419ff523a (patch) | |
tree | 76447e104bfafeea83f3df6cf7f540d7c0bf048c /bridge/slack/helpers_test.go | |
parent | 5ed7abdbeb8a81599b3516583e15df75651fb9bc (diff) | |
download | matterbridge-msglm-f5659d455d2c28a6f2fe4c40f4dc344419ff523a.tar.gz matterbridge-msglm-f5659d455d2c28a6f2fe4c40f4dc344419ff523a.tar.bz2 matterbridge-msglm-f5659d455d2c28a6f2fe4c40f4dc344419ff523a.zip |
Sync channel topics between Slack bridges (#585)
Added logic to allow for configurable synchronisation of topics and purposes of channels between Slack bridges.
Diffstat (limited to 'bridge/slack/helpers_test.go')
-rw-r--r-- | bridge/slack/helpers_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/bridge/slack/helpers_test.go b/bridge/slack/helpers_test.go new file mode 100644 index 00000000..c9ff647d --- /dev/null +++ b/bridge/slack/helpers_test.go @@ -0,0 +1,36 @@ +package bslack + +import ( + "io/ioutil" + "testing" + + "github.com/42wim/matterbridge/bridge" + "github.com/sirupsen/logrus" + "github.com/stretchr/testify/assert" +) + +func TestExtractTopicOrPurpose(t *testing.T) { + testcases := map[string]struct { + input string + wantChangeType string + wantOutput string + }{ + "success - topic type": {"@someone set channel topic: foo bar", "topic", "foo bar"}, + "success - purpose type": {"@someone set channel purpose: foo bar", "purpose", "foo bar"}, + "success - one line": {"@someone set channel topic: foo bar", "topic", "foo bar"}, + "success - multi-line": {"@someone set channel topic: foo\nbar", "topic", "foo\nbar"}, + "success - cleared": {"@someone cleared channel topic", "topic", ""}, + "error - unhandled": {"some unmatched message", "unknown", ""}, + } + + logger := logrus.New() + logger.SetOutput(ioutil.Discard) + cfg := &bridge.Config{Log: logger.WithFields(nil)} + b := newBridge(cfg) + for name, tc := range testcases { + gotChangeType, gotOutput := b.extractTopicOrPurpose(tc.input) + + assert.Equalf(t, tc.wantChangeType, gotChangeType, "This testcase failed: %s", name) + assert.Equalf(t, tc.wantOutput, gotOutput, "This testcase failed: %s", name) + } +} |