nathanpeck / s3-upload-stream

A Node.js module for streaming data to Amazon S3 via the multipart upload API
MIT License
347 stars 46 forks source link

Expose AWSstub so that users of the library can easily mock their tests #37

Closed agconti closed 6 years ago

agconti commented 9 years ago

Since other devs will probably need to mock AWS so they can test the uploads in their application, it makes sense to expose AWSstub as a connivence utility.

nathanpeck commented 9 years ago

Thanks for the suggestion. However I will not be merging this in because in my opinion it is better for devs to pass in their own custom implementation of the AWS stub, since the one for the tests in s3-upload-stream is setup to trigger different behavior when certain filenames are used, specific to internal unit tests for the module itself.

If your goal is to unit test uploads in your own app then you may choose to copy the stub from the s3-upload-stream and use it as a template to implement your own stub in your unit test suite. By doing this you would have more control to trigger certain error conditions as needed.

But exposing the stub from the unit tests as a first class citizen of the module is a little too hacky in my opinion.

agconti commented 6 years ago

👍