github.com/wgh-/mattermost-server@v4.8.0-rc2+incompatible/model/compliance_post_test.go (about)

     1  // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package model
     5  
     6  import (
     7  	"testing"
     8  )
     9  
    10  func TestCompliancePostHeader(t *testing.T) {
    11  	if CompliancePostHeader()[0] != "TeamName" {
    12  		t.Fatal()
    13  	}
    14  }
    15  
    16  func TestCompliancePost(t *testing.T) {
    17  	o := CompliancePost{TeamName: "test", PostFileIds: "files", PostCreateAt: GetMillis()}
    18  	r := o.Row()
    19  
    20  	if r[0] != "test" {
    21  		t.Fatal()
    22  	}
    23  
    24  	if r[len(r)-1] != "files" {
    25  		t.Fatal()
    26  	}
    27  }
    28  
    29  var cleanTests = []struct {
    30  	in       string
    31  	expected string
    32  }{
    33  	{"hello", "hello"},
    34  	{"=hello", "'=hello"},
    35  	{"+hello", "'+hello"},
    36  	{"-hello", "'-hello"},
    37  	{"  =hello", "'  =hello"},
    38  	{"  +hello", "'  +hello"},
    39  	{"  -hello", "'  -hello"},
    40  	{"\t  -hello", "'\t  -hello"},
    41  }
    42  
    43  func TestCleanComplianceStrings(t *testing.T) {
    44  	for _, tt := range cleanTests {
    45  		actual := cleanComplianceStrings(tt.in)
    46  		if actual != tt.expected {
    47  			t.Errorf("cleanComplianceStrings(%v): expected %v, actual %v", tt.in, tt.expected, actual)
    48  		}
    49  	}
    50  }