diff --git a/localstack/init/ready.d/s3.sh b/localstack/init/ready.d/s3.sh index 70af45b..8456e35 100755 --- a/localstack/init/ready.d/s3.sh +++ b/localstack/init/ready.d/s3.sh @@ -5,7 +5,7 @@ BUCKET="test-jslib-aws" # The localstack exposes its init script in the `/etc/localstack/init` folder. # For convinience we've setup a `testdata` folder in the same directory. testdata_folder="/etc/localstack/init/testdata/s3" -testdata_files="bonjour.txt tschuss.txt delete.txt" +testdata_files="bonjour.txt tschuss.txt delete.txt mandrill.tiff" # Create the test-jslib-aws bucket awslocal s3api create-bucket \ diff --git a/localstack/init/testdata/s3/mandrill.tiff b/localstack/init/testdata/s3/mandrill.tiff new file mode 100644 index 0000000..017ce58 Binary files /dev/null and b/localstack/init/testdata/s3/mandrill.tiff differ diff --git a/tests/index.js b/tests/index.js index 7ea2685..f8833c9 100644 --- a/tests/index.js +++ b/tests/index.js @@ -58,6 +58,10 @@ const testData = { key: 'delete.txt', body: 'Delete me in a test!', }, + { + key: 'mandrill.tiff', + body: open('../localstack/init/testdata/s3/mandrill.tiff', 'b'), + }, ], }, diff --git a/tests/internal/s3.js b/tests/internal/s3.js index cc8f8bf..c1fd824 100644 --- a/tests/internal/s3.js +++ b/tests/internal/s3.js @@ -28,10 +28,11 @@ export async function s3TestSuite(data) { // Assert expect(objects).to.be.an('array') - expect(objects).to.have.lengthOf(3) + expect(objects).to.have.lengthOf(4) expect(objects[0].key).to.equal('bonjour.txt') expect(objects[1].key).to.equal('delete.txt') expect(objects[2].key).to.equal('tschuss.txt') + expect(objects[3].key).to.equal('mandrill.tiff') }) await asyncDescribe('s3.getObject', async (expect) => { @@ -46,6 +47,12 @@ export async function s3TestSuite(data) { data.s3.testObjects[1].key ) + const gotBinaryObject = await s3Client.getObject( + data.s3.testBucketName, + data.s3.testObjects[3].key, + 'binary' + ) + let getObjectFromNonExistingBucketError try { await s3Client.getObject('non-existent-bucket', data.s3.testObjects[0].key) @@ -67,6 +74,9 @@ export async function s3TestSuite(data) { expect(gotSecondObject).to.be.an('object') expect(gotSecondObject.key).to.equal(data.s3.testObjects[1].key) expect(gotSecondObject.data).to.equal(data.s3.testObjects[1].body) + expect(gotBinaryObject).to.be.an('object') + expect(gotBinaryObject.key).to.equal(data.s3.testObjects[3].key) + expect(gotBinaryObject.data).to.equal(data.s3.testObjects[3].body) expect(getObjectFromNonExistingBucketError).to.not.be.undefined expect(getObjectFromNonExistingBucketError).to.be.an.instanceOf(S3ServiceError) expect(getNonExistingObjectError).to.not.be.undefined