summaryrefslogtreecommitdiffstats
path: root/model/incoming_webhook_test.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2015-10-19 14:24:02 -0400
committerHarrison Healey <harrisonmhealey@gmail.com>2015-10-19 14:24:02 -0400
commitd139c9e825d0149329d90684ebe2d6b31a728b16 (patch)
tree484dfe912010791e4eef9fa0152a4b1e3ba987e9 /model/incoming_webhook_test.go
parentfd69910fab332642a7793e64064169e89eb0c3de (diff)
parentc7d00de68291f5a53353c1391d4548d3f2ec7c0c (diff)
downloadchat-d139c9e825d0149329d90684ebe2d6b31a728b16.tar.gz
chat-d139c9e825d0149329d90684ebe2d6b31a728b16.tar.bz2
chat-d139c9e825d0149329d90684ebe2d6b31a728b16.zip
Merge pull request #1108 from mattermost/plt-235
PLT-235 Implement outgoing webhooks.
Diffstat (limited to 'model/incoming_webhook_test.go')
-rw-r--r--model/incoming_webhook_test.go82
1 files changed, 82 insertions, 0 deletions
diff --git a/model/incoming_webhook_test.go b/model/incoming_webhook_test.go
new file mode 100644
index 000000000..5297d7d90
--- /dev/null
+++ b/model/incoming_webhook_test.go
@@ -0,0 +1,82 @@
+// Copyright (c) 2015 Mattermost, 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()
+}