summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-07-20 08:18:05 -0400
committerJoramWilander <jwawilander@gmail.com>2015-07-21 19:22:04 -0400
commit04408eea375439d69b61d65155fea863b3b1834c (patch)
tree8c13ccfe6b9bbf39a2897108f7aa0eeaecb40b41 /api
parent25cfe548e6e41f3e2972f5b22c4191af7459f3e1 (diff)
downloadchat-04408eea375439d69b61d65155fea863b3b1834c.tar.gz
chat-04408eea375439d69b61d65155fea863b3b1834c.tar.bz2
chat-04408eea375439d69b61d65155fea863b3b1834c.zip
updated create profile image unit test to clean up images properly
Diffstat (limited to 'api')
-rw-r--r--api/user_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/api/user_test.go b/api/user_test.go
index 6cd47defa..e236adeaf 100644
--- a/api/user_test.go
+++ b/api/user_test.go
@@ -356,6 +356,24 @@ func TestUserCreateImage(t *testing.T) {
Client.DoGet("/users/"+user.Id+"/image", "", "")
+ if utils.IsS3Configured() && !utils.Cfg.ServiceSettings.UseLocalStorage {
+ var auth aws.Auth
+ auth.AccessKey = utils.Cfg.AWSSettings.S3AccessKeyId
+ auth.SecretKey = utils.Cfg.AWSSettings.S3SecretAccessKey
+
+ s := s3.New(auth, aws.Regions[utils.Cfg.AWSSettings.S3Region])
+ bucket := s.Bucket(utils.Cfg.AWSSettings.S3Bucket)
+
+ if err := bucket.Del("teams/" + user.TeamId + "/users/" + user.Id + "/profile.png"); err != nil {
+ t.Fatal(err)
+ }
+ } else {
+ path := utils.Cfg.ServiceSettings.StorageDirectory + "teams/" + user.TeamId + "/users/" + user.Id + "/profile.png"
+ if err := os.Remove(path); err != nil {
+ t.Fatal("Couldn't remove file at " + path)
+ }
+ }
+
}
func TestUserUploadProfileImage(t *testing.T) {