summaryrefslogtreecommitdiffstats
path: root/model/webhook_test.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2015-09-22 15:47:57 -0400
committerJoram Wilander <jwawilander@gmail.com>2015-09-22 15:47:57 -0400
commitac7918c5540900ab0dbe43d61b8c1155e4279b55 (patch)
tree2e519e101e995d24d656d7cf1f7a9d404303a364 /model/webhook_test.go
parenta44e8f0cd904d386caea410398dcaf7dbfd9c138 (diff)
parent98186e5018bbc604796d4f9762c93f4f75e2913f (diff)
downloadchat-ac7918c5540900ab0dbe43d61b8c1155e4279b55.tar.gz
chat-ac7918c5540900ab0dbe43d61b8c1155e4279b55.tar.bz2
chat-ac7918c5540900ab0dbe43d61b8c1155e4279b55.zip
Merge pull request #715 from mattermost/plt-27
PLT-27 Implement incoming webhooks.
Diffstat (limited to 'model/webhook_test.go')
-rw-r--r--model/webhook_test.go82
1 files changed, 82 insertions, 0 deletions
diff --git a/model/webhook_test.go b/model/webhook_test.go
new file mode 100644
index 000000000..ddbe18cd3
--- /dev/null
+++ b/model/webhook_test.go
@@ -0,0 +1,82 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestIncomingWebhookJson(t *testing.T) {
+ o := IncomingWebhook{Id: NewId()}
+ json := o.ToJson()
+ ro := IncomingWebhookFromJson(strings.NewReader(json))
+
+ if o.Id != ro.Id {
+ t.Fatal("Ids do not match")
+ }
+}
+
+func TestIncomingWebhookIsValid(t *testing.T) {
+ o := IncomingWebhook{}
+
+ if err := o.IsValid(); err == nil {
+ t.Fatal("should be invalid")
+ }
+
+ o.Id = NewId()
+ if err := o.IsValid(); err == nil {
+ t.Fatal("should be invalid")
+ }
+
+ o.CreateAt = GetMillis()
+ if err := o.IsValid(); err == nil {
+ t.Fatal("should be invalid")
+ }
+
+ o.UpdateAt = GetMillis()
+ if err := o.IsValid(); err == nil {
+ t.Fatal("should be invalid")
+ }
+
+ o.UserId = "123"
+ if err := o.IsValid(); err == nil {
+ t.Fatal("should be invalid")
+ }
+
+ o.UserId = NewId()
+ if err := o.IsValid(); err == nil {
+ t.Fatal("should be invalid")
+ }
+
+ o.ChannelId = "123"
+ if err := o.IsValid(); err == nil {
+ t.Fatal("should be invalid")
+ }
+
+ o.ChannelId = NewId()
+ if err := o.IsValid(); err == nil {
+ t.Fatal("should be invalid")
+ }
+
+ o.TeamId = "123"
+ if err := o.IsValid(); err == nil {
+ t.Fatal("should be invalid")
+ }
+
+ o.TeamId = NewId()
+ if err := o.IsValid(); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestIncomingWebhookPreSave(t *testing.T) {
+ o := IncomingWebhook{}
+ o.PreSave()
+}
+
+func TestIncomingWebhookPreUpdate(t *testing.T) {
+ o := IncomingWebhook{}
+ o.PreUpdate()
+}