forked from lug/matterbridge
		
	Sync channel topics between Slack bridges (#585)
Added logic to allow for configurable synchronisation of topics and purposes of channels between Slack bridges.
This commit is contained in:
		 Patrick Connolly
					Patrick Connolly
				
			
				
					committed by
					
						 Duco van Amstel
						Duco van Amstel
					
				
			
			
				
	
			
			
			 Duco van Amstel
						Duco van Amstel
					
				
			
						parent
						
							5ed7abdbeb
						
					
				
				
					commit
					f5659d455d
				
			
							
								
								
									
										36
									
								
								bridge/slack/helpers_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								bridge/slack/helpers_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -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) | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user