Skip to content

Commit

Permalink
tentative fix for the maxKeys==0 bug + unit test
Browse files Browse the repository at this point in the history
Issue #250
  • Loading branch information
jonathan-gramain committed May 2, 2017
1 parent 06281f7 commit 1db5909
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/algos/list/delimiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class Delimiter extends Extension {
this.delimiter = parameters.delimiter;
this.prefix = parameters.prefix;
this.marker = parameters.marker;
this.maxKeys = parameters.maxKeys || 1000;
this.maxKeys = (parameters.maxKeys !== undefined ?
parameters.maxKeys : 1000);
// results
this.CommonPrefixes = [];
this.Contents = [];
Expand Down Expand Up @@ -99,8 +100,8 @@ class Delimiter extends Extension {
*/
_reachedMaxKeys() {
if (this.keys >= this.maxKeys) {
// In cases of maxKeys <= 0 -> IsTruncated = false
this.IsTruncated = this.maxKeys > 0;
// In cases of maxKeys < 0 -> IsTruncated = false
this.IsTruncated = this.maxKeys >= 0;
return true;
}
return false;
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/algos/list/delimiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ const tests = [
IsTruncated: false,
NextMarker: undefined,
}),
new Test('with zero makKeys', {
maxKeys: 0,
}, {
Contents: [],
CommonPrefixes: [],
Delimiter: undefined,
IsTruncated: true,
NextMarker: undefined,
}),
new Test('with delimiter', {
delimiter: '/',
}, {
Expand Down

0 comments on commit 1db5909

Please sign in to comment.