Add test cases

This commit is contained in:
Lena Fuhrimann 2017-04-03 22:31:14 +02:00
parent bd11b4ce45
commit 3cdb649365
2 changed files with 44 additions and 2 deletions

View file

@ -75,11 +75,11 @@ func icon(fileName string) string {
e := path.Ext(fileName) e := path.Ext(fileName)
switch e { switch e {
case ".tgz": case ".tgz", ".gz":
return "archive" return "archive"
case ".png", ".jpg", ".gif", ".svg": case ".png", ".jpg", ".gif", ".svg":
return "photo" return "photo"
case ".mp3": case ".mp3", ".wav":
return "music_note" return "music_note"
} }

View file

@ -27,11 +27,53 @@ func TestBucketViewHandler(t *testing.T) {
Buckets: []minio.BucketInfo{ Buckets: []minio.BucketInfo{
{Name: "testBucket"}, {Name: "testBucket"},
}, },
ObjectInfos: []minio.ObjectInfo{
{Key: "testFile"},
},
}, },
bucketName: "testBucket", bucketName: "testBucket",
expectedStatusCode: http.StatusOK, expectedStatusCode: http.StatusOK,
expectedBodyCountains: "testBucket", 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": { "bucket doesn't exist": {
s3: &S3ClientMock{}, s3: &S3ClientMock{},
bucketName: "testBucket", bucketName: "testBucket",