Skip to content

Commit

Permalink
allowing empty params in overrides (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Poetzsch-Heffter authored and flovilmart committed Jan 10, 2017
1 parent d496264 commit c10ba46
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/optionsFromArguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ const optionsFromArguments = function optionsFromArguments(args) {
} else if (args.length == 2) {
Object.assign(options, stringOrOptions);
s3overrides = args[1];
options.bucket = s3overrides.params.Bucket;

if (s3overrides.params) {
options.bucket = s3overrides.params.Bucket;
}
} else if (args.length > 2) {
throw new Error('Failed to configure S3Adapter. Arguments don\'t make sense');
}
Expand Down
10 changes: 10 additions & 0 deletions spec/test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ describe('S3Adapter tests', () => {
expect(s3._s3Client.config.params.Bucket).toEqual('bucket-2');
expect(s3._bucketPrefix).toEqual('test/');
});

it('should accept overrides without params', () => {
var confObj = { bucketPrefix: 'test/', bucket: 'bucket-1', secretKey: 'secret-1', accessKey: 'key-1' };
var overridesObj = { secretAccessKey: 'secret-2'};
var s3 = new S3Adapter(confObj, overridesObj);
expect(s3._s3Client.config.accessKeyId).toEqual('key-1');
expect(s3._s3Client.config.secretAccessKey).toEqual('secret-2');
expect(s3._s3Client.config.params.Bucket).toEqual('bucket-1');
expect(s3._bucketPrefix).toEqual('test/');
});
});

describe('getFileLocation', () => {
Expand Down

0 comments on commit c10ba46

Please sign in to comment.