blob: 81de50c6bd1594058da9da9ab88ddbbb882e95aa (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package model
import (
"strings"
"testing"
)
func TestEmojiIsValid(t *testing.T) {
emoji := Emoji{
Id: NewId(),
CreateAt: 1234,
UpdateAt: 1234,
DeleteAt: 0,
CreatorId: NewId(),
Name: "name",
}
if err := emoji.IsValid(); err != nil {
t.Fatal(err)
}
emoji.Id = "1234"
if err := emoji.IsValid(); err == nil {
t.Fatal()
}
emoji.Id = NewId()
emoji.CreateAt = 0
if err := emoji.IsValid(); err == nil {
t.Fatal()
}
emoji.CreateAt = 1234
emoji.UpdateAt = 0
if err := emoji.IsValid(); err == nil {
t.Fatal()
}
emoji.UpdateAt = 1234
emoji.CreatorId = strings.Repeat("1", 25)
if err := emoji.IsValid(); err == nil {
t.Fatal()
}
emoji.CreatorId = strings.Repeat("1", 27)
if err := emoji.IsValid(); err == nil {
t.Fatal()
}
emoji.CreatorId = NewId()
emoji.Name = strings.Repeat("1", 65)
if err := emoji.IsValid(); err == nil {
t.Fatal()
}
emoji.Name = strings.Repeat("1", 64)
if err := emoji.IsValid(); err != nil {
t.Fatal(err)
}
}
|