Skip to content

Commit

Permalink
docs: revise start-after in listV2
Browse files Browse the repository at this point in the history
  • Loading branch information
beajer committed Dec 9, 2020
1 parent df18401 commit 31743e4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2357,13 +2357,13 @@ const result = await store.listV2({
console.log(result.objects);
```
- List `a/` dir objects, after `a/b` and include `a/b`
- List `a/` dir objects, after `a/b` and not include `a/b`
```js
const result = await store.listV2({
delimiter: '/',
prefix: 'a/',
'start-after': 'b'
'start-after': 'a/b'
});
console.log(result.objects);
```
Expand Down
24 changes: 23 additions & 1 deletion test/browser/browser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@ describe('browser', () => {
});

it('should list with start-afer', async () => {
// todo
let result = await store.listV2({
'start-after': `${listPrefix}fun`,
'max-keys': 1
Expand All @@ -594,6 +593,29 @@ describe('browser', () => {
});
assert(result.objects.length === 1);
assert(result.objects[0].name === `${listPrefix}fun/movie/007.avi`);

result = await store.listV2({
prefix: `${listPrefix}`,
'max-keys': 5,
'start-after': `${listPrefix}a`,
delimiter: '/'
});
assert.strictEqual(result.keyCount, 3);
assert.strictEqual(result.objects.length, 1);
assert.strictEqual(result.objects[0].name, `${listPrefix}oss.jpg`);
assert.strictEqual(result.prefixes.length, 2);
assert.strictEqual(result.prefixes[0], `${listPrefix}fun/`);
assert.strictEqual(result.prefixes[1], `${listPrefix}other/`);

result = await store.listV2({
prefix: `${listPrefix}`,
'max-keys': 5,
'start-after': `${listPrefix}oss.jpg`,
delimiter: '/'
});
assert.strictEqual(result.keyCount, 1);
assert.strictEqual(result.objects, undefined);
assert.strictEqual(result.prefixes[0], `${listPrefix}other/`);
});

it('should list with continuation-token', async () => {
Expand Down
24 changes: 23 additions & 1 deletion test/node/object.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,6 @@ describe('test/object.test.js', () => {
});

it('should list with start-afer', async () => {
// todo
let result = await store.listV2({
'start-after': `${listPrefix}fun`,
'max-keys': 1
Expand All @@ -1968,6 +1967,29 @@ describe('test/object.test.js', () => {
});
assert(result.objects.length === 1);
assert(result.objects[0].name === `${listPrefix}fun/movie/007.avi`);

result = await store.listV2({
prefix: `${listPrefix}`,
'max-keys': 5,
'start-after': `${listPrefix}a`,
delimiter: '/'
});
assert.strictEqual(result.keyCount, 3);
assert.strictEqual(result.objects.length, 1);
assert.strictEqual(result.objects[0].name, `${listPrefix}oss.jpg`);
assert.strictEqual(result.prefixes.length, 2);
assert.strictEqual(result.prefixes[0], `${listPrefix}fun/`);
assert.strictEqual(result.prefixes[1], `${listPrefix}other/`);

result = await store.listV2({
prefix: `${listPrefix}`,
'max-keys': 5,
'start-after': `${listPrefix}oss.jpg`,
delimiter: '/'
});
assert.strictEqual(result.keyCount, 1);
assert.strictEqual(result.objects, undefined);
assert.strictEqual(result.prefixes[0], `${listPrefix}other/`);
});

it('should list with continuation-token', async () => {
Expand Down

0 comments on commit 31743e4

Please sign in to comment.