From 273da4daa3e464c95669d388974e6190813ef3e7 Mon Sep 17 00:00:00 2001 From: taotao7 Date: Wed, 26 Jan 2022 16:34:46 +0800 Subject: [PATCH 1/2] fix: test case optimized --- karma.conf.js | 2 +- test/browser/browser-utils.js | 2 +- test/browser/browser.test.js | 33 +++++++++++++++++++++++---------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index b6319d480..fc5d15188 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -11,7 +11,7 @@ module.exports = function (config) { require('karma-firefox-launcher'), require('karma-safari-launcher') ], - browsers: isCiEnv ? ['ChromeHeadless'] : ['Chrome', 'Safari', 'Firefox'], + browsers: isCiEnv ? ['ChromeHeadless'] : ['Firefox'], files: ['test/browser/build/aliyun-oss-sdk.min.js', 'test/browser/build/tests.js'], // preprocessors: { // 'dist/aliyun-oss-sdk.js': ['coverage'] 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 4e79c689b..be2041aec 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); @@ -2367,9 +2383,6 @@ describe('browser', () => { }, { parallel: 4, partSize: 1024 * 1024, - progress: (p) => { - console.log(p); - } }); assert.equal(result.res.statusCode, 200); }); From 95866f160e78f46e9d684be67dea0816d4969ca0 Mon Sep 17 00:00:00 2001 From: moca_tao7 Date: Wed, 26 Jan 2022 16:42:08 +0800 Subject: [PATCH 2/2] checkout karma.config checkout karma.config --- karma.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karma.conf.js b/karma.conf.js index fc5d15188..b6319d480 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -11,7 +11,7 @@ module.exports = function (config) { require('karma-firefox-launcher'), require('karma-safari-launcher') ], - browsers: isCiEnv ? ['ChromeHeadless'] : ['Firefox'], + browsers: isCiEnv ? ['ChromeHeadless'] : ['Chrome', 'Safari', 'Firefox'], files: ['test/browser/build/aliyun-oss-sdk.min.js', 'test/browser/build/tests.js'], // preprocessors: { // 'dist/aliyun-oss-sdk.js': ['coverage']