This commit is contained in:
Lena Fuhrimann 2017-04-18 15:43:13 +02:00
parent 6778d23090
commit 0c6ab519c6
2 changed files with 37 additions and 37 deletions

View file

@ -20,7 +20,7 @@ func TestBucketViewHandler(t *testing.T) {
s3 S3Client
bucketName string
expectedStatusCode int
expectedBodyCountains string
expectedBodyContains string
}{
"success (empty bucket)": {
s3: &S3ClientMock{
@ -30,7 +30,7 @@ func TestBucketViewHandler(t *testing.T) {
},
bucketName: "testBucket",
expectedStatusCode: http.StatusOK,
expectedBodyCountains: "No objects in",
expectedBodyContains: "No objects in",
},
"success (with file)": {
s3: &S3ClientMock{
@ -43,7 +43,7 @@ func TestBucketViewHandler(t *testing.T) {
},
bucketName: "testBucket",
expectedStatusCode: http.StatusOK,
expectedBodyCountains: "testBucket",
expectedBodyContains: "testBucket",
},
"success (archive)": {
s3: &S3ClientMock{
@ -56,7 +56,7 @@ func TestBucketViewHandler(t *testing.T) {
},
bucketName: "testBucket",
expectedStatusCode: http.StatusOK,
expectedBodyCountains: "archive",
expectedBodyContains: "archive",
},
"success (image)": {
s3: &S3ClientMock{
@ -69,7 +69,7 @@ func TestBucketViewHandler(t *testing.T) {
},
bucketName: "testBucket",
expectedStatusCode: http.StatusOK,
expectedBodyCountains: "photo",
expectedBodyContains: "photo",
},
"success (sound)": {
s3: &S3ClientMock{
@ -82,13 +82,13 @@ func TestBucketViewHandler(t *testing.T) {
},
bucketName: "testBucket",
expectedStatusCode: http.StatusOK,
expectedBodyCountains: "music_note",
expectedBodyContains: "music_note",
},
"bucket doesn't exist": {
s3: &S3ClientMock{},
bucketName: "testBucket",
expectedStatusCode: http.StatusNotFound,
expectedBodyCountains: http.StatusText(http.StatusNotFound),
expectedBodyContains: http.StatusText(http.StatusNotFound),
},
"s3 error": {
s3: &S3ClientMock{
@ -96,7 +96,7 @@ func TestBucketViewHandler(t *testing.T) {
},
bucketName: "testBucket",
expectedStatusCode: http.StatusInternalServerError,
expectedBodyCountains: http.StatusText(http.StatusInternalServerError),
expectedBodyContains: http.StatusText(http.StatusInternalServerError),
},
}
@ -119,6 +119,6 @@ func TestBucketViewHandler(t *testing.T) {
assert.NoError(err, tcID)
assert.Equal(tc.expectedStatusCode, resp.StatusCode, tcID)
assert.Contains(string(body), tc.expectedBodyCountains, tcID)
assert.Contains(string(body), tc.expectedBodyContains, tcID)
}
}

View file

@ -20,7 +20,7 @@ func TestGetObjectHandler(t *testing.T) {
bucketName string
objectName string
expectedStatusCode int
expectedBodyCountains string
expectedBodyContains string
}{
"s3 error": {
s3: &S3ClientMock{
@ -29,7 +29,7 @@ func TestGetObjectHandler(t *testing.T) {
bucketName: "testBucket",
objectName: "testObject",
expectedStatusCode: http.StatusInternalServerError,
expectedBodyCountains: http.StatusText(http.StatusInternalServerError),
expectedBodyContains: http.StatusText(http.StatusInternalServerError),
},
}
@ -52,6 +52,6 @@ func TestGetObjectHandler(t *testing.T) {
assert.NoError(err, tcID)
assert.Equal(tc.expectedStatusCode, resp.StatusCode, tcID)
assert.Contains(string(body), tc.expectedBodyCountains, tcID)
assert.Contains(string(body), tc.expectedBodyContains, tcID)
}
}