summaryrefslogtreecommitdiffstats
path: root/model/audits_test.go
blob: 3b22b26683dc5316335112e835c297b5a9b8379a (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
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

package model

import (
	"strings"
	"testing"
)

func TestAuditsJson(t *testing.T) {
	audit := Audit{Id: NewId(), UserId: NewId(), CreateAt: GetMillis()}
	json := audit.ToJson()
	result := AuditFromJson(strings.NewReader(json))

	if audit.Id != result.Id {
		t.Fatal("Ids do not match")
	}

	var audits Audits = make([]Audit, 1)
	audits[0] = audit

	ljson := audits.ToJson()
	results := AuditsFromJson(strings.NewReader(ljson))

	if audits[0].Id != results[0].Id {
		t.Fatal("Ids do not match")
	}
}