summaryrefslogtreecommitdiffstats
path: root/app/post_test.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-09-06 17:12:54 -0500
committerGitHub <noreply@github.com>2017-09-06 17:12:54 -0500
commit1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3 (patch)
tree2766bacc1f045fa685ca3d8310cd6174d0311d09 /app/post_test.go
parentb84bd21089d305333fa4114b95be70f5ad94ad1b (diff)
downloadchat-1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3.tar.gz
chat-1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3.tar.bz2
chat-1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3.zip
app type transition (#7167)
Diffstat (limited to 'app/post_test.go')
-rw-r--r--app/post_test.go25
1 files changed, 14 insertions, 11 deletions
diff --git a/app/post_test.go b/app/post_test.go
index ab8e27021..e7084325e 100644
--- a/app/post_test.go
+++ b/app/post_test.go
@@ -19,13 +19,14 @@ import (
)
func TestUpdatePostEditAt(t *testing.T) {
- th := Setup().InitBasic()
+ a := Global()
+ th := a.Setup().InitBasic()
post := &model.Post{}
*post = *th.BasicPost
post.IsPinned = true
- if saved, err := UpdatePost(post, true); err != nil {
+ if saved, err := a.UpdatePost(post, true); err != nil {
t.Fatal(err)
} else if saved.EditAt != post.EditAt {
t.Fatal("shouldn't have updated post.EditAt when pinning post")
@@ -36,7 +37,7 @@ func TestUpdatePostEditAt(t *testing.T) {
time.Sleep(time.Millisecond * 100)
post.Message = model.NewId()
- if saved, err := UpdatePost(post, true); err != nil {
+ if saved, err := a.UpdatePost(post, true); err != nil {
t.Fatal(err)
} else if saved.EditAt == post.EditAt {
t.Fatal("should have updated post.EditAt when updating post message")
@@ -44,20 +45,21 @@ func TestUpdatePostEditAt(t *testing.T) {
}
func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) {
+ a := Global()
// This test ensures that when replying to a root post made by a user who has since left the channel, the reply
// post completes successfully. This is a regression test for PLT-6523.
- th := Setup().InitBasic()
+ th := a.Setup().InitBasic()
channel := th.BasicChannel
userInChannel := th.BasicUser2
userNotInChannel := th.BasicUser
rootPost := th.BasicPost
- if _, err := AddUserToChannel(userInChannel, channel); err != nil {
+ if _, err := a.AddUserToChannel(userInChannel, channel); err != nil {
t.Fatal(err)
}
- if err := RemoveUserFromChannel(userNotInChannel.Id, "", channel); err != nil {
+ if err := a.RemoveUserFromChannel(userNotInChannel.Id, "", channel); err != nil {
t.Fatal(err)
}
@@ -71,13 +73,14 @@ func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) {
CreateAt: 0,
}
- if _, err := CreatePostAsUser(&replyPost); err != nil {
+ if _, err := a.CreatePostAsUser(&replyPost); err != nil {
t.Fatal(err)
}
}
func TestPostAction(t *testing.T) {
- th := Setup().InitBasic()
+ a := Global()
+ th := a.Setup().InitBasic()
allowedInternalConnections := *utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections
defer func() {
@@ -122,7 +125,7 @@ func TestPostAction(t *testing.T) {
},
}
- post, err := CreatePostAsUser(&interactivePost)
+ post, err := a.CreatePostAsUser(&interactivePost)
require.Nil(t, err)
attachments, ok := post.Props["attachments"].([]*model.SlackAttachment)
@@ -131,10 +134,10 @@ func TestPostAction(t *testing.T) {
require.NotEmpty(t, attachments[0].Actions)
require.NotEmpty(t, attachments[0].Actions[0].Id)
- err = DoPostAction(post.Id, "notavalidid", th.BasicUser.Id)
+ err = a.DoPostAction(post.Id, "notavalidid", th.BasicUser.Id)
require.NotNil(t, err)
assert.Equal(t, http.StatusNotFound, err.StatusCode)
- err = DoPostAction(post.Id, attachments[0].Actions[0].Id, th.BasicUser.Id)
+ err = a.DoPostAction(post.Id, attachments[0].Actions[0].Id, th.BasicUser.Id)
require.Nil(t, err)
}