Fix typo
This commit is contained in:
parent
6778d23090
commit
0c6ab519c6
2 changed files with 37 additions and 37 deletions
|
@ -17,10 +17,10 @@ func TestBucketViewHandler(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
tests := map[string]struct {
|
tests := map[string]struct {
|
||||||
s3 S3Client
|
s3 S3Client
|
||||||
bucketName string
|
bucketName string
|
||||||
expectedStatusCode int
|
expectedStatusCode int
|
||||||
expectedBodyCountains string
|
expectedBodyContains string
|
||||||
}{
|
}{
|
||||||
"success (empty bucket)": {
|
"success (empty bucket)": {
|
||||||
s3: &S3ClientMock{
|
s3: &S3ClientMock{
|
||||||
|
@ -28,9 +28,9 @@ func TestBucketViewHandler(t *testing.T) {
|
||||||
{Name: "testBucket"},
|
{Name: "testBucket"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
bucketName: "testBucket",
|
bucketName: "testBucket",
|
||||||
expectedStatusCode: http.StatusOK,
|
expectedStatusCode: http.StatusOK,
|
||||||
expectedBodyCountains: "No objects in",
|
expectedBodyContains: "No objects in",
|
||||||
},
|
},
|
||||||
"success (with file)": {
|
"success (with file)": {
|
||||||
s3: &S3ClientMock{
|
s3: &S3ClientMock{
|
||||||
|
@ -41,9 +41,9 @@ func TestBucketViewHandler(t *testing.T) {
|
||||||
{Key: "testFile"},
|
{Key: "testFile"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
bucketName: "testBucket",
|
bucketName: "testBucket",
|
||||||
expectedStatusCode: http.StatusOK,
|
expectedStatusCode: http.StatusOK,
|
||||||
expectedBodyCountains: "testBucket",
|
expectedBodyContains: "testBucket",
|
||||||
},
|
},
|
||||||
"success (archive)": {
|
"success (archive)": {
|
||||||
s3: &S3ClientMock{
|
s3: &S3ClientMock{
|
||||||
|
@ -54,9 +54,9 @@ func TestBucketViewHandler(t *testing.T) {
|
||||||
{Key: "archive.tar.gz"},
|
{Key: "archive.tar.gz"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
bucketName: "testBucket",
|
bucketName: "testBucket",
|
||||||
expectedStatusCode: http.StatusOK,
|
expectedStatusCode: http.StatusOK,
|
||||||
expectedBodyCountains: "archive",
|
expectedBodyContains: "archive",
|
||||||
},
|
},
|
||||||
"success (image)": {
|
"success (image)": {
|
||||||
s3: &S3ClientMock{
|
s3: &S3ClientMock{
|
||||||
|
@ -67,9 +67,9 @@ func TestBucketViewHandler(t *testing.T) {
|
||||||
{Key: "testImage.png"},
|
{Key: "testImage.png"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
bucketName: "testBucket",
|
bucketName: "testBucket",
|
||||||
expectedStatusCode: http.StatusOK,
|
expectedStatusCode: http.StatusOK,
|
||||||
expectedBodyCountains: "photo",
|
expectedBodyContains: "photo",
|
||||||
},
|
},
|
||||||
"success (sound)": {
|
"success (sound)": {
|
||||||
s3: &S3ClientMock{
|
s3: &S3ClientMock{
|
||||||
|
@ -80,23 +80,23 @@ func TestBucketViewHandler(t *testing.T) {
|
||||||
{Key: "testSound.mp3"},
|
{Key: "testSound.mp3"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
bucketName: "testBucket",
|
bucketName: "testBucket",
|
||||||
expectedStatusCode: http.StatusOK,
|
expectedStatusCode: http.StatusOK,
|
||||||
expectedBodyCountains: "music_note",
|
expectedBodyContains: "music_note",
|
||||||
},
|
},
|
||||||
"bucket doesn't exist": {
|
"bucket doesn't exist": {
|
||||||
s3: &S3ClientMock{},
|
s3: &S3ClientMock{},
|
||||||
bucketName: "testBucket",
|
bucketName: "testBucket",
|
||||||
expectedStatusCode: http.StatusNotFound,
|
expectedStatusCode: http.StatusNotFound,
|
||||||
expectedBodyCountains: http.StatusText(http.StatusNotFound),
|
expectedBodyContains: http.StatusText(http.StatusNotFound),
|
||||||
},
|
},
|
||||||
"s3 error": {
|
"s3 error": {
|
||||||
s3: &S3ClientMock{
|
s3: &S3ClientMock{
|
||||||
Err: errors.New("mocked S3 error"),
|
Err: errors.New("mocked S3 error"),
|
||||||
},
|
},
|
||||||
bucketName: "testBucket",
|
bucketName: "testBucket",
|
||||||
expectedStatusCode: http.StatusInternalServerError,
|
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.NoError(err, tcID)
|
||||||
|
|
||||||
assert.Equal(tc.expectedStatusCode, resp.StatusCode, tcID)
|
assert.Equal(tc.expectedStatusCode, resp.StatusCode, tcID)
|
||||||
assert.Contains(string(body), tc.expectedBodyCountains, tcID)
|
assert.Contains(string(body), tc.expectedBodyContains, tcID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,20 +16,20 @@ func TestGetObjectHandler(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
tests := map[string]struct {
|
tests := map[string]struct {
|
||||||
s3 S3Client
|
s3 S3Client
|
||||||
bucketName string
|
bucketName string
|
||||||
objectName string
|
objectName string
|
||||||
expectedStatusCode int
|
expectedStatusCode int
|
||||||
expectedBodyCountains string
|
expectedBodyContains string
|
||||||
}{
|
}{
|
||||||
"s3 error": {
|
"s3 error": {
|
||||||
s3: &S3ClientMock{
|
s3: &S3ClientMock{
|
||||||
Err: errors.New("mocked S3 error"),
|
Err: errors.New("mocked S3 error"),
|
||||||
},
|
},
|
||||||
bucketName: "testBucket",
|
bucketName: "testBucket",
|
||||||
objectName: "testObject",
|
objectName: "testObject",
|
||||||
expectedStatusCode: http.StatusInternalServerError,
|
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.NoError(err, tcID)
|
||||||
|
|
||||||
assert.Equal(tc.expectedStatusCode, resp.StatusCode, tcID)
|
assert.Equal(tc.expectedStatusCode, resp.StatusCode, tcID)
|
||||||
assert.Contains(string(body), tc.expectedBodyCountains, tcID)
|
assert.Contains(string(body), tc.expectedBodyContains, tcID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue