From 3cdb649365e66b24869cc89f3b7730e30bf84992 Mon Sep 17 00:00:00 2001 From: Lena Fuhrimann <6780471+cloudlena@users.noreply.github.com> Date: Mon, 3 Apr 2017 22:31:14 +0200 Subject: [PATCH] Add test cases --- bucket-view.go | 4 ++-- bucket-view_test.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/bucket-view.go b/bucket-view.go index a86ffc2..1e96423 100644 --- a/bucket-view.go +++ b/bucket-view.go @@ -75,11 +75,11 @@ func icon(fileName string) string { e := path.Ext(fileName) switch e { - case ".tgz": + case ".tgz", ".gz": return "archive" case ".png", ".jpg", ".gif", ".svg": return "photo" - case ".mp3": + case ".mp3", ".wav": return "music_note" } diff --git a/bucket-view_test.go b/bucket-view_test.go index 084422e..3fddc3d 100644 --- a/bucket-view_test.go +++ b/bucket-view_test.go @@ -27,11 +27,53 @@ func TestBucketViewHandler(t *testing.T) { Buckets: []minio.BucketInfo{ {Name: "testBucket"}, }, + ObjectInfos: []minio.ObjectInfo{ + {Key: "testFile"}, + }, }, bucketName: "testBucket", expectedStatusCode: http.StatusOK, expectedBodyCountains: "testBucket", }, + "success (archive)": { + s3: &S3ClientMock{ + Buckets: []minio.BucketInfo{ + {Name: "testBucket"}, + }, + ObjectInfos: []minio.ObjectInfo{ + {Key: "archive.tar.gz"}, + }, + }, + bucketName: "testBucket", + expectedStatusCode: http.StatusOK, + expectedBodyCountains: "archive", + }, + "success (image)": { + s3: &S3ClientMock{ + Buckets: []minio.BucketInfo{ + {Name: "testBucket"}, + }, + ObjectInfos: []minio.ObjectInfo{ + {Key: "testImage.png"}, + }, + }, + bucketName: "testBucket", + expectedStatusCode: http.StatusOK, + expectedBodyCountains: "photo", + }, + "success (sound)": { + s3: &S3ClientMock{ + Buckets: []minio.BucketInfo{ + {Name: "testBucket"}, + }, + ObjectInfos: []minio.ObjectInfo{ + {Key: "testSound.mp3"}, + }, + }, + bucketName: "testBucket", + expectedStatusCode: http.StatusOK, + expectedBodyCountains: "music_note", + }, "bucket doesn't exist": { s3: &S3ClientMock{}, bucketName: "testBucket",