diff options
author | Saturnino Abril <saturnino.abril@gmail.com> | 2017-03-01 10:18:36 +0900 |
---|---|---|
committer | enahum <nahumhbl@gmail.com> | 2017-02-28 22:18:36 -0300 |
commit | 28c218db3bbdcc0776be1be91ff4acbd0586f590 (patch) | |
tree | 10259512af822b378a93e105cb2608e039324001 /api4/file_test.go | |
parent | 2a621f7470476b0f10d6241a13fdcfd838748edd (diff) | |
download | chat-28c218db3bbdcc0776be1be91ff4acbd0586f590.tar.gz chat-28c218db3bbdcc0776be1be91ff4acbd0586f590.tar.bz2 chat-28c218db3bbdcc0776be1be91ff4acbd0586f590.zip |
Implementation endpoint of APIv4: GET /files/{file_id}/thumbnail (#5553)
* APIv4: GET /files/{file_id}/thumbnail
* added delay time
Diffstat (limited to 'api4/file_test.go')
-rw-r--r-- | api4/file_test.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/api4/file_test.go b/api4/file_test.go index d47dd6cb1..f8f57cdb8 100644 --- a/api4/file_test.go +++ b/api4/file_test.go @@ -149,3 +149,55 @@ func TestGetFile(t *testing.T) { _, resp = th.SystemAdminClient.GetFile(fileId) CheckNoError(t, resp) } + +func TestGetFileThumbnail(t *testing.T) { + th := Setup().InitBasic().InitSystemAdmin() + defer TearDown() + Client := th.Client + channel := th.BasicChannel + + if utils.Cfg.FileSettings.DriverName == "" { + t.Skip("skipping because no file driver is enabled") + } + + fileId := "" + var sent []byte + var err error + if sent, err = readTestFile("test.png"); err != nil { + t.Fatal(err) + } else { + fileResp, resp := Client.UploadFile(sent, channel.Id, "test.png") + CheckNoError(t, resp) + + fileId = fileResp.FileInfos[0].Id + } + + // Wait a bit for files to ready + time.Sleep(2 * time.Second) + + data, resp := Client.GetFileThumbnail(fileId) + CheckNoError(t, resp) + + if data == nil || len(data) == 0 { + t.Fatal("should not be empty") + } + + _, resp = Client.GetFileThumbnail("junk") + CheckBadRequestStatus(t, resp) + + _, resp = Client.GetFileThumbnail(model.NewId()) + CheckNotFoundStatus(t, resp) + + Client.Logout() + _, resp = Client.GetFileThumbnail(fileId) + CheckUnauthorizedStatus(t, resp) + + otherUser := th.CreateUser() + Client.Login(otherUser.Email, otherUser.Password) + _, resp = Client.GetFileThumbnail(fileId) + CheckForbiddenStatus(t, resp) + + Client.Logout() + _, resp = th.SystemAdminClient.GetFileThumbnail(fileId) + CheckNoError(t, resp) +} |