summaryrefslogtreecommitdiffstats
path: root/model/post_test.go
diff options
context:
space:
mode:
authorMartin Kraft <martinkraft@gmail.com>2018-03-27 09:01:42 -0400
committerMartin Kraft <martinkraft@gmail.com>2018-03-27 09:01:42 -0400
commite13e64711f7a7e8ceadb8cbc6af72c4022c95b36 (patch)
treefe0e956b1d660cd08d41757d25c8adcb3463568c /model/post_test.go
parentd8b42070186c12f6320fe54ea1c405149846404c (diff)
parent9e6db178b09387e21ac19ce85369cf1ca7a443e8 (diff)
downloadchat-e13e64711f7a7e8ceadb8cbc6af72c4022c95b36.tar.gz
chat-e13e64711f7a7e8ceadb8cbc6af72c4022c95b36.tar.bz2
chat-e13e64711f7a7e8ceadb8cbc6af72c4022c95b36.zip
Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-1
Diffstat (limited to 'model/post_test.go')
-rw-r--r--model/post_test.go31
1 files changed, 16 insertions, 15 deletions
diff --git a/model/post_test.go b/model/post_test.go
index 5d5e7c9ec..af350d76e 100644
--- a/model/post_test.go
+++ b/model/post_test.go
@@ -23,72 +23,73 @@ func TestPostJson(t *testing.T) {
func TestPostIsValid(t *testing.T) {
o := Post{}
+ maxPostSize := 10000
- if err := o.IsValid(); err == nil {
+ if err := o.IsValid(maxPostSize); err == nil {
t.Fatal("should be invalid")
}
o.Id = NewId()
- if err := o.IsValid(); err == nil {
+ if err := o.IsValid(maxPostSize); err == nil {
t.Fatal("should be invalid")
}
o.CreateAt = GetMillis()
- if err := o.IsValid(); err == nil {
+ if err := o.IsValid(maxPostSize); err == nil {
t.Fatal("should be invalid")
}
o.UpdateAt = GetMillis()
- if err := o.IsValid(); err == nil {
+ if err := o.IsValid(maxPostSize); err == nil {
t.Fatal("should be invalid")
}
o.UserId = NewId()
- if err := o.IsValid(); err == nil {
+ if err := o.IsValid(maxPostSize); err == nil {
t.Fatal("should be invalid")
}
o.ChannelId = NewId()
o.RootId = "123"
- if err := o.IsValid(); err == nil {
+ if err := o.IsValid(maxPostSize); err == nil {
t.Fatal("should be invalid")
}
o.RootId = ""
o.ParentId = "123"
- if err := o.IsValid(); err == nil {
+ if err := o.IsValid(maxPostSize); err == nil {
t.Fatal("should be invalid")
}
o.ParentId = NewId()
o.RootId = ""
- if err := o.IsValid(); err == nil {
+ if err := o.IsValid(maxPostSize); err == nil {
t.Fatal("should be invalid")
}
o.ParentId = ""
- o.Message = strings.Repeat("0", 4001)
- if err := o.IsValid(); err == nil {
+ o.Message = strings.Repeat("0", maxPostSize+1)
+ if err := o.IsValid(maxPostSize); err == nil {
t.Fatal("should be invalid")
}
- o.Message = strings.Repeat("0", 4000)
- if err := o.IsValid(); err != nil {
+ o.Message = strings.Repeat("0", maxPostSize)
+ if err := o.IsValid(maxPostSize); err != nil {
t.Fatal(err)
}
o.Message = "test"
- if err := o.IsValid(); err != nil {
+ if err := o.IsValid(maxPostSize); err != nil {
t.Fatal(err)
}
o.Type = "junk"
- if err := o.IsValid(); err == nil {
+ if err := o.IsValid(maxPostSize); err == nil {
t.Fatal("should be invalid")
}
o.Type = POST_CUSTOM_TYPE_PREFIX + "type"
- if err := o.IsValid(); err != nil {
+ if err := o.IsValid(maxPostSize); err != nil {
t.Fatal(err)
}
}