Skip to content

Commit

Permalink
feat: add test cases for browser append()
Browse files Browse the repository at this point in the history
  • Loading branch information
csg01123119 committed Jul 12, 2023
1 parent 39ef9ac commit 71e3245
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/browser/browser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2449,4 +2449,38 @@ describe('browser', () => {
assert.equal(header['x-oss-server-side-encryption'], undefined);
});
});

describe.only('append()', () => {
const name = `/${prefix}ali-sdk/oss/apend${Date.now()}`;
let store;
before(() => {
store = oss(ossConfig);
});

afterEach(async () => {
await store.delete(name);
});

it('should apend object with content blob', async () => {
let object = await store.append(name, new Blob(['foo']));
assert(object.res.status === 200);
assert(object.nextAppendPosition === '3');
assert(object.res.headers['x-oss-next-append-position'] === '3');

let res = await store.get(name);
assert(res.content.toString() === 'foo');
assert(res.res.headers['x-oss-next-append-position'] === '3');

object = await store.append(name, new Blob(['bar']), {
position: 3
});
assert(object.res.status === 200);
assert(object.nextAppendPosition === '6');
assert(object.res.headers['x-oss-next-append-position'] === '6');

res = await store.get(name);
assert(res.content.toString() === 'foobar');
assert(res.res.headers['x-oss-next-append-position'] === '6');
});
});
});

0 comments on commit 71e3245

Please sign in to comment.