summaryrefslogtreecommitdiffstats
path: root/model/compliance_post_test.go
blob: 21044c1281d11470a43aab1b15c181a532083871 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

package model

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestCompliancePostHeader(t *testing.T) {
	require.Equal(t, "TeamName", CompliancePostHeader()[0])
}

func TestCompliancePost(t *testing.T) {
	o := CompliancePost{TeamName: "test", PostFileIds: "files", PostCreateAt: GetMillis()}
	r := o.Row()

	require.Equal(t, "test", r[0])
	require.Equal(t, "files", r[len(r)-1])
}

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)
		}
	}
}