Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allowing empty params in overrides #38

Merged
merged 1 commit into from
Jan 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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