summaryrefslogtreecommitdiffstats
path: root/api4/file_test.go
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-08-25 15:38:13 +0100
committerHarrison Healey <harrisonmhealey@gmail.com>2017-08-25 10:38:13 -0400
commit50fc6e1e9e8d286fd6a406cef75e48a28f9427ad (patch)
tree0689de640729194b9a123ec8bfef36cbecd8cefd /api4/file_test.go
parent99acf6106833a2186c0f7e07985feac5d9c25de1 (diff)
downloadchat-50fc6e1e9e8d286fd6a406cef75e48a28f9427ad.tar.gz
chat-50fc6e1e9e8d286fd6a406cef75e48a28f9427ad.tar.bz2
chat-50fc6e1e9e8d286fd6a406cef75e48a28f9427ad.zip
PLT-???? Prepare file upload infrastructure for Data Retention. (#7266)
* Prepare file upload infrastructure for Data Retention. This commit prepares the file upload infrastructure for the data retention feature that is under construction. Changes are: * Move file management code to utils to allow access to it from jobs. * From now on, store all file uploads in a top level folder which is the date of the day on which they were uploaded. This commit is based on Harrison Healey's branch, but updated to work with the latest master. * Use NewAppError
Diffstat (limited to 'api4/file_test.go')
-rw-r--r--api4/file_test.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/api4/file_test.go b/api4/file_test.go
index c2bc926e1..a2673dc8e 100644
--- a/api4/file_test.go
+++ b/api4/file_test.go
@@ -71,20 +71,22 @@ func TestUploadFile(t *testing.T) {
t.Fatal("file preview path should be set in database")
}
+ date := time.Now().Format("20060102")
+
// This also makes sure that the relative path provided above is sanitized out
- expectedPath := fmt.Sprintf("teams/%v/channels/%v/users/%v/%v/test.png", FILE_TEAM_ID, channel.Id, user.Id, info.Id)
+ expectedPath := fmt.Sprintf("%v/teams/%v/channels/%v/users/%v/%v/test.png", date, FILE_TEAM_ID, channel.Id, user.Id, info.Id)
if info.Path != expectedPath {
t.Logf("file is saved in %v", info.Path)
t.Fatalf("file should've been saved in %v", expectedPath)
}
- expectedThumbnailPath := fmt.Sprintf("teams/%v/channels/%v/users/%v/%v/test_thumb.jpg", FILE_TEAM_ID, channel.Id, user.Id, info.Id)
+ expectedThumbnailPath := fmt.Sprintf("%v/teams/%v/channels/%v/users/%v/%v/test_thumb.jpg", date, FILE_TEAM_ID, channel.Id, user.Id, info.Id)
if info.ThumbnailPath != expectedThumbnailPath {
t.Logf("file thumbnail is saved in %v", info.ThumbnailPath)
t.Fatalf("file thumbnail should've been saved in %v", expectedThumbnailPath)
}
- expectedPreviewPath := fmt.Sprintf("teams/%v/channels/%v/users/%v/%v/test_preview.jpg", FILE_TEAM_ID, channel.Id, user.Id, info.Id)
+ expectedPreviewPath := fmt.Sprintf("%v/teams/%v/channels/%v/users/%v/%v/test_preview.jpg", date, FILE_TEAM_ID, channel.Id, user.Id, info.Id)
if info.PreviewPath != expectedPreviewPath {
t.Logf("file preview is saved in %v", info.PreviewPath)
t.Fatalf("file preview should've been saved in %v", expectedPreviewPath)