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",