From e8eed0a19faa27fb54a2de6591b3ef582dcc9e07 Mon Sep 17 00:00:00 2001 From: moca_tao7 Date: Wed, 26 Jan 2022 16:59:58 +0800 Subject: [PATCH] fix(test): test case optimized (#1044) --- test/browser/browser-utils.js | 2 +- test/browser/browser.test.js | 51 ++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/test/browser/browser-utils.js b/test/browser/browser-utils.js index 0f3818a3f..da8d75df6 100644 --- a/test/browser/browser-utils.js +++ b/test/browser/browser-utils.js @@ -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) { diff --git a/test/browser/browser.test.js b/test/browser/browser.test.js index ae80c791c..857e48fb3 100644 --- a/test/browser/browser.test.js +++ b/test/browser/browser.test.js @@ -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', @@ -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, @@ -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); @@ -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: { @@ -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); @@ -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); }); });