2017-04-12 08:27:57 -04:00
|
|
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
2016-03-10 09:39:05 -08:00
|
|
|
// See License.txt for license information.
|
|
|
|
|
|
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestCompliancePostHeader(t *testing.T) {
|
|
|
|
|
if CompliancePostHeader()[0] != "TeamName" {
|
|
|
|
|
t.Fatal()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestCompliancePost(t *testing.T) {
|
2016-09-30 11:06:30 -04:00
|
|
|
o := CompliancePost{TeamName: "test", PostFileIds: "files", PostCreateAt: GetMillis()}
|
2016-03-10 09:39:05 -08:00
|
|
|
r := o.Row()
|
|
|
|
|
|
|
|
|
|
if r[0] != "test" {
|
|
|
|
|
t.Fatal()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if r[len(r)-1] != "files" {
|
|
|
|
|
t.Fatal()
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-07-28 09:32:37 -06:00
|
|
|
|
|
|
|
|
var cleanTests = []struct {
|
|
|
|
|
in string
|
|
|
|
|
expected string
|
|
|
|
|
}{
|
|
|
|
|
{"hello", "hello"},
|
|
|
|
|
{"=hello", "'=hello"},
|
|
|
|
|
{"+hello", "'+hello"},
|
|
|
|
|
{"-hello", "'-hello"},
|
|
|
|
|
{" =hello", "' =hello"},
|
|
|
|
|
{" +hello", "' +hello"},
|
|
|
|
|
{" -hello", "' -hello"},
|
|
|
|
|
{"\t -hello", "'\t -hello"},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestCleanComplianceStrings(t *testing.T) {
|
|
|
|
|
for _, tt := range cleanTests {
|
|
|
|
|
actual := cleanComplianceStrings(tt.in)
|
|
|
|
|
if actual != tt.expected {
|
|
|
|
|
t.Errorf("cleanComplianceStrings(%v): expected %v, actual %v", tt.in, tt.expected, actual)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|