summaryrefslogtreecommitdiffstats
path: root/api/slackimport_test.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-11-04 17:20:21 -0400
committerHarrison Healey <harrisonmhealey@gmail.com>2016-11-04 17:20:21 -0400
commit18745b2d5c1899bc279696548cb3ebecf7c6b90f (patch)
tree23cf9a3f8a75a89970792dd6ce0ff5b26df82850 /api/slackimport_test.go
parent20254073cb9976e783875f997a291829e6a0d78d (diff)
downloadchat-18745b2d5c1899bc279696548cb3ebecf7c6b90f.tar.gz
chat-18745b2d5c1899bc279696548cb3ebecf7c6b90f.tar.bz2
chat-18745b2d5c1899bc279696548cb3ebecf7c6b90f.zip
Increase Channel Purpose length to 250, and add channel field length handling code to the slack importer (#4458)
* Increase Channel Purpose length to 250. This commit increases the maxmimum length of the channel purpose field to 250, including the database migration necessary. It also adds a method to the Slack importer to check the lengths of channel properties before importing, and truncate them if necessary. Fixes #4168 * Fix database migration.
Diffstat (limited to 'api/slackimport_test.go')
-rw-r--r--api/slackimport_test.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/api/slackimport_test.go b/api/slackimport_test.go
index 81b79b3d1..d78424ac0 100644
--- a/api/slackimport_test.go
+++ b/api/slackimport_test.go
@@ -4,7 +4,9 @@
package api
import (
+ "github.com/mattermost/platform/model"
"os"
+ "strings"
"testing"
)
@@ -177,3 +179,41 @@ func TestSlackParsePosts(t *testing.T) {
t.Fatalf("Unexpected number of posts: %v", len(posts))
}
}
+
+func TestSlackSanitiseChannelProperties(t *testing.T) {
+ c1 := model.Channel{
+ DisplayName: "display-name",
+ Name: "name",
+ Purpose: "The channel purpose",
+ Header: "The channel header",
+ }
+
+ c1s := SlackSanitiseChannelProperties(c1)
+ if c1.DisplayName != c1s.DisplayName || c1.Name != c1s.Name || c1.Purpose != c1s.Purpose || c1.Header != c1s.Header {
+ t.Fatalf("Unexpected alterations to the channel properties.")
+ }
+
+ c2 := model.Channel{
+ DisplayName: strings.Repeat("abcdefghij", 7),
+ Name: strings.Repeat("abcdefghij", 7),
+ Purpose: strings.Repeat("0123456789", 30),
+ Header: strings.Repeat("0123456789", 120),
+ }
+
+ c2s := SlackSanitiseChannelProperties(c2)
+ if c2s.DisplayName != strings.Repeat("abcdefghij", 6)+"abcd" {
+ t.Fatalf("Unexpected alterations to the channel properties: %v", c2s.DisplayName)
+ }
+
+ if c2s.Name != strings.Repeat("abcdefghij", 6)+"abcd" {
+ t.Fatalf("Unexpected alterations to the channel properties: %v", c2s.Name)
+ }
+
+ if c2s.Purpose != strings.Repeat("0123456789", 25) {
+ t.Fatalf("Unexpected alterations to the channel properties: %v", c2s.Purpose)
+ }
+
+ if c2s.Header != strings.Repeat("0123456789", 102)+"0123" {
+ t.Fatalf("Unexpected alterations to the channel properties: %v", c2s.Header)
+ }
+}