diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2018-05-30 10:48:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-30 10:48:04 -0400 |
commit | 2fe88787492077af294ee82a8775304f655c8805 (patch) | |
tree | bd119c4baf0d484ecb1df59f890b2190824364a6 /model/config_test.go | |
parent | 81852ab1911f9bc3234c35683bb5fae83b57d863 (diff) | |
download | chat-2fe88787492077af294ee82a8775304f655c8805.tar.gz chat-2fe88787492077af294ee82a8775304f655c8805.tar.bz2 chat-2fe88787492077af294ee82a8775304f655c8805.zip |
MM-9547 Added config setting to control url autolinking schemes (#8862)
* MM-9547 Added config setting to control autolinking schemes
* Renamed AutolinkingSchemes to CustomUrlSchemes
Diffstat (limited to 'model/config_test.go')
-rw-r--r-- | model/config_test.go | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/model/config_test.go b/model/config_test.go index b7533145b..5406d680d 100644 --- a/model/config_test.go +++ b/model/config_test.go @@ -436,3 +436,86 @@ func TestMessageExportSetDefaultsExportDisabledExportFromTimestampNonZero(t *tes require.Equal(t, int64(0), *mes.ExportFromTimestamp) require.Equal(t, 10000, *mes.BatchSize) } + +func TestDisplaySettingsIsValidCustomUrlSchemes(t *testing.T) { + tests := []struct { + name string + value []string + valid bool + }{ + { + name: "empty", + value: []string{}, + valid: true, + }, + { + name: "custom protocol", + value: []string{"steam"}, + valid: true, + }, + { + name: "multiple custom protocols", + value: []string{"bitcoin", "rss", "redis"}, + valid: true, + }, + { + name: "containing numbers", + value: []string{"ut2004", "ts3server", "h323"}, + valid: true, + }, + { + name: "containing period", + value: []string{"iris.beep"}, + valid: true, + }, + { + name: "containing hyphen", + value: []string{"ms-excel"}, + valid: true, + }, + { + name: "containing plus", + value: []string{"coap+tcp", "coap+ws"}, + valid: true, + }, + { + name: "starting with number", + value: []string{"4four"}, + valid: false, + }, + { + name: "starting with period", + value: []string{"data", ".dot"}, + valid: false, + }, + { + name: "starting with hyphen", + value: []string{"-hyphen", "dns"}, + valid: false, + }, + { + name: "invalid symbols", + value: []string{"!!fun!!"}, + valid: false, + }, + { + name: "invalid letters", + value: []string{"école"}, + valid: false, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + ds := &DisplaySettings{} + ds.SetDefaults() + + ds.CustomUrlSchemes = &test.value + + if err := ds.isValid(); err != nil && test.valid { + t.Error("Expected CustomUrlSchemes to be valid but got error:", err) + } else if err == nil && !test.valid { + t.Error("Expected CustomUrlSchemes to be invalid but got no error") + } + }) + } +} |