diff options
author | Chris <ccbrown112@gmail.com> | 2017-09-21 04:13:34 -0500 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2017-09-21 10:13:34 +0100 |
commit | 266ff8670244da288aec937320d9eecc7996af35 (patch) | |
tree | 39e4e528cda0abb24be317683516ee246717fc68 /api/post_test.go | |
parent | adab1a660fdc0c307238279edc7a9918d14577e5 (diff) | |
download | chat-266ff8670244da288aec937320d9eecc7996af35.tar.gz chat-266ff8670244da288aec937320d9eecc7996af35.tar.bz2 chat-266ff8670244da288aec937320d9eecc7996af35.zip |
remove more global refs (#7480)
Diffstat (limited to 'api/post_test.go')
-rw-r--r-- | api/post_test.go | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/api/post_test.go b/api/post_test.go index f571aacd1..1fb6b3ded 100644 --- a/api/post_test.go +++ b/api/post_test.go @@ -1187,30 +1187,30 @@ func TestGetFlaggedPosts(t *testing.T) { } func TestGetMessageForNotification(t *testing.T) { - Setup().InitBasic() + th := Setup().InitBasic() - testPng := store.Must(app.Global().Srv.Store.FileInfo().Save(&model.FileInfo{ + testPng := store.Must(th.App.Srv.Store.FileInfo().Save(&model.FileInfo{ CreatorId: model.NewId(), Path: "test1.png", Name: "test1.png", MimeType: "image/png", })).(*model.FileInfo) - testJpg1 := store.Must(app.Global().Srv.Store.FileInfo().Save(&model.FileInfo{ + testJpg1 := store.Must(th.App.Srv.Store.FileInfo().Save(&model.FileInfo{ CreatorId: model.NewId(), Path: "test2.jpg", Name: "test2.jpg", MimeType: "image/jpeg", })).(*model.FileInfo) - testFile := store.Must(app.Global().Srv.Store.FileInfo().Save(&model.FileInfo{ + testFile := store.Must(th.App.Srv.Store.FileInfo().Save(&model.FileInfo{ CreatorId: model.NewId(), Path: "test1.go", Name: "test1.go", MimeType: "text/plain", })).(*model.FileInfo) - testJpg2 := store.Must(app.Global().Srv.Store.FileInfo().Save(&model.FileInfo{ + testJpg2 := store.Must(th.App.Srv.Store.FileInfo().Save(&model.FileInfo{ CreatorId: model.NewId(), Path: "test3.jpg", Name: "test3.jpg", @@ -1224,39 +1224,39 @@ func TestGetMessageForNotification(t *testing.T) { Message: "test", } - if app.Global().GetMessageForNotification(post, translateFunc) != "test" { + if th.App.GetMessageForNotification(post, translateFunc) != "test" { t.Fatal("should've returned message text") } post.FileIds = model.StringArray{testPng.Id} - store.Must(app.Global().Srv.Store.FileInfo().AttachToPost(testPng.Id, post.Id)) - if app.Global().GetMessageForNotification(post, translateFunc) != "test" { + store.Must(th.App.Srv.Store.FileInfo().AttachToPost(testPng.Id, post.Id)) + if th.App.GetMessageForNotification(post, translateFunc) != "test" { t.Fatal("should've returned message text, even with attachments") } post.Message = "" - if message := app.Global().GetMessageForNotification(post, translateFunc); message != "1 image sent: test1.png" { + if message := th.App.GetMessageForNotification(post, translateFunc); message != "1 image sent: test1.png" { t.Fatal("should've returned number of images:", message) } post.FileIds = model.StringArray{testPng.Id, testJpg1.Id} - store.Must(app.Global().Srv.Store.FileInfo().AttachToPost(testJpg1.Id, post.Id)) - app.Global().Srv.Store.FileInfo().InvalidateFileInfosForPostCache(post.Id) - if message := app.Global().GetMessageForNotification(post, translateFunc); message != "2 images sent: test1.png, test2.jpg" && message != "2 images sent: test2.jpg, test1.png" { + store.Must(th.App.Srv.Store.FileInfo().AttachToPost(testJpg1.Id, post.Id)) + th.App.Srv.Store.FileInfo().InvalidateFileInfosForPostCache(post.Id) + if message := th.App.GetMessageForNotification(post, translateFunc); message != "2 images sent: test1.png, test2.jpg" && message != "2 images sent: test2.jpg, test1.png" { t.Fatal("should've returned number of images:", message) } post.Id = model.NewId() post.FileIds = model.StringArray{testFile.Id} - store.Must(app.Global().Srv.Store.FileInfo().AttachToPost(testFile.Id, post.Id)) - if message := app.Global().GetMessageForNotification(post, translateFunc); message != "1 file sent: test1.go" { + store.Must(th.App.Srv.Store.FileInfo().AttachToPost(testFile.Id, post.Id)) + if message := th.App.GetMessageForNotification(post, translateFunc); message != "1 file sent: test1.go" { t.Fatal("should've returned number of files:", message) } - store.Must(app.Global().Srv.Store.FileInfo().AttachToPost(testJpg2.Id, post.Id)) - app.Global().Srv.Store.FileInfo().InvalidateFileInfosForPostCache(post.Id) + store.Must(th.App.Srv.Store.FileInfo().AttachToPost(testJpg2.Id, post.Id)) + th.App.Srv.Store.FileInfo().InvalidateFileInfosForPostCache(post.Id) post.FileIds = model.StringArray{testFile.Id, testJpg2.Id} - if message := app.Global().GetMessageForNotification(post, translateFunc); message != "2 files sent: test1.go, test3.jpg" && message != "2 files sent: test3.jpg, test1.go" { + if message := th.App.GetMessageForNotification(post, translateFunc); message != "2 files sent: test1.go, test3.jpg" && message != "2 files sent: test3.jpg, test1.go" { t.Fatal("should've returned number of mixed files:", message) } } |