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

fix(test): test case optimized #1044

Merged
merged 3 commits into from
Jan 26, 2022
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
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