Skip to content

Commit

Permalink
fix(test): test case optimized (#1044)
Browse files Browse the repository at this point in the history
  • Loading branch information
taotao7 authored Jan 26, 2022
1 parent 4fc3bd4 commit e8eed0a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
2 changes: 1 addition & 1 deletion test/browser/browser-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const platform = require('platform');

if (process && process.browser) {
exports.prefix = `${platform.name}-${platform.version}/`;
exports.prefix = `${platform.name}-${platform.version}-${new Date().valueOf()}/`;
} else {
exports.prefix = `${process.platform}-${process.version}/`;
if (process && process.execPath.indexOf('iojs') >= 0) {
Expand Down
51 changes: 30 additions & 21 deletions test/browser/browser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ describe('browser', () => {
});

describe('endpoint', () => {
it('should init with region', () => {
console.log('xxx');
});
it('should init with region', () => {
let store = oss({
accessKeyId: 'foo',
Expand Down Expand Up @@ -805,8 +802,11 @@ describe('browser', () => {
// let otherBucketObject;
let store;
before(async () => {
name = `${prefix}ali-sdk/oss/copy-meta.js`;
store = oss(ossConfig);
});

it('should copy object from same bucket', async () => {
name = `${prefix}ali-sdk/oss/copy-sameBucket-meta.js`;
const object = await store.put(name, Buffer.from('abc'), {
meta: {
uid: 1,
Expand All @@ -815,9 +815,6 @@ describe('browser', () => {
}
});
assert.equal(typeof object.res.headers['x-oss-request-id'], 'string');
});

it('should copy object from same bucket', async () => {
const originname = `${prefix}ali-sdk/oss/copy-new.js`;
const result = await store.copy(originname, name);
assert.equal(result.res.status, 200);
Expand Down Expand Up @@ -908,6 +905,16 @@ describe('browser', () => {
});

it('should copy object and set other meta', async () => {
name = `${prefix}ali-sdk/oss/copy-setOther-meta.js`;
const object = await store.put(name, Buffer.from('abc'), {
meta: {
uid: 3,
pid: '123',
slus: 'test.html'
}
});
assert.equal(typeof object.res.headers['x-oss-request-id'], 'string');

const originname = `${prefix}ali-sdk/oss/copy-new-2.js`;
const result = await store.copy(originname, name, {
meta: {
Expand All @@ -927,6 +934,15 @@ describe('browser', () => {
});

it('should use copy to change exists object headers', async () => {
name = `${prefix}ali-sdk/oss/copy-objectHeader-meta.js`;
const object = await store.put(name, Buffer.from('abc'), {
meta: {
uid: 5,
pid: '123',
slus: 'test.html'
}
});
assert.equal(typeof object.res.headers['x-oss-request-id'], 'string');
const originname = `${prefix}ali-sdk/oss/copy-new-3.js`;
let result = await store.copy(originname, name);
assert.equal(result.res.status, 200);
Expand Down Expand Up @@ -2362,20 +2378,13 @@ describe('browser', () => {
const client = oss(ossConfig);
const copyName = 'multipart copy';
const key = 'old.txt';
const result = await client.multipartUploadCopy(
copyName,
{
sourceKey: key,
sourceBucketName: stsConfig.bucket
},
{
parallel: 4,
partSize: 1024 * 1024,
progress: p => {
console.log(p);
}
}
);
const result = await client.multipartUploadCopy(copyName, {
sourceKey: key,
sourceBucketName: stsConfig.bucket
}, {
parallel: 4,
partSize: 1024 * 1024,
});
assert.equal(result.res.statusCode, 200);
});
});
Expand Down

0 comments on commit e8eed0a

Please sign in to comment.