summaryrefslogtreecommitdiffstats
path: root/app/post_test.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-09-12 09:19:52 -0500
committerGitHub <noreply@github.com>2017-09-12 09:19:52 -0500
commitb066b6df138e88e75cb40f1ec3e58fbd13e61909 (patch)
tree7ee0e8c935cd3bbafd15d0d07d8900af8b82a4e0 /app/post_test.go
parent674a606bd00b276d0a05b3b29a3d5f5e5e7f8206 (diff)
downloadchat-b066b6df138e88e75cb40f1ec3e58fbd13e61909.tar.gz
chat-b066b6df138e88e75cb40f1ec3e58fbd13e61909.tar.bz2
chat-b066b6df138e88e75cb40f1ec3e58fbd13e61909.zip
Remove global app references (#7433)
* remove global app references * test fix * fix api4 test compilation
Diffstat (limited to 'app/post_test.go')
-rw-r--r--app/post_test.go25
1 files changed, 11 insertions, 14 deletions
diff --git a/app/post_test.go b/app/post_test.go
index e0e9b52b6..92eb8857e 100644
--- a/app/post_test.go
+++ b/app/post_test.go
@@ -19,14 +19,13 @@ import (
)
func TestUpdatePostEditAt(t *testing.T) {
- a := Global()
- th := a.Setup().InitBasic()
+ th := Setup().InitBasic()
post := &model.Post{}
*post = *th.BasicPost
post.IsPinned = true
- if saved, err := a.UpdatePost(post, true); err != nil {
+ if saved, err := th.App.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")
@@ -37,7 +36,7 @@ func TestUpdatePostEditAt(t *testing.T) {
time.Sleep(time.Millisecond * 100)
post.Message = model.NewId()
- if saved, err := a.UpdatePost(post, true); err != nil {
+ if saved, err := th.App.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")
@@ -45,21 +44,20 @@ 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 := a.Setup().InitBasic()
+ th := Setup().InitBasic()
channel := th.BasicChannel
userInChannel := th.BasicUser2
userNotInChannel := th.BasicUser
rootPost := th.BasicPost
- if _, err := a.AddUserToChannel(userInChannel, channel); err != nil {
+ if _, err := th.App.AddUserToChannel(userInChannel, channel); err != nil {
t.Fatal(err)
}
- if err := a.RemoveUserFromChannel(userNotInChannel.Id, "", channel); err != nil {
+ if err := th.App.RemoveUserFromChannel(userNotInChannel.Id, "", channel); err != nil {
t.Fatal(err)
}
@@ -73,14 +71,13 @@ func TestPostReplyToPostWhereRootPosterLeftChannel(t *testing.T) {
CreateAt: 0,
}
- if _, err := a.CreatePostAsUser(&replyPost); err != nil {
+ if _, err := th.App.CreatePostAsUser(&replyPost); err != nil {
t.Fatal(err)
}
}
func TestPostAction(t *testing.T) {
- a := Global()
- th := a.Setup().InitBasic()
+ th := Setup().InitBasic()
allowedInternalConnections := *utils.Cfg.ServiceSettings.AllowedUntrustedInternalConnections
defer func() {
@@ -125,7 +122,7 @@ func TestPostAction(t *testing.T) {
},
}
- post, err := a.CreatePostAsUser(&interactivePost)
+ post, err := th.App.CreatePostAsUser(&interactivePost)
require.Nil(t, err)
attachments, ok := post.Props["attachments"].([]*model.SlackAttachment)
@@ -134,10 +131,10 @@ func TestPostAction(t *testing.T) {
require.NotEmpty(t, attachments[0].Actions)
require.NotEmpty(t, attachments[0].Actions[0].Id)
- err = a.DoPostAction(post.Id, "notavalidid", th.BasicUser.Id)
+ err = th.App.DoPostAction(post.Id, "notavalidid", th.BasicUser.Id)
require.NotNil(t, err)
assert.Equal(t, http.StatusNotFound, err.StatusCode)
- err = a.DoPostAction(post.Id, attachments[0].Actions[0].Id, th.BasicUser.Id)
+ err = th.App.DoPostAction(post.Id, attachments[0].Actions[0].Id, th.BasicUser.Id)
require.Nil(t, err)
}