Skip to content

Commit 33b8277

Browse files
committed
fix test cases
1 parent 198a197 commit 33b8277

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

test/form_up.test.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,19 @@ before(function () {
2727
});
2828

2929
after(function () {
30-
return Promise.all([
31-
fs.promises.unlink(testFilePath1),
32-
fs.promises.unlink(testFilePath2)
33-
])
34-
.catch(err => {
35-
console.log('Form upload test. Unlink files failed', err);
36-
});
30+
return Promise.all(
31+
[
32+
testFilePath1,
33+
testFilePath2
34+
].map(p => new Promise(resolve => {
35+
fs.unlink(p, err => {
36+
if (err) {
37+
console.log(`unlink ${p} failed`, err);
38+
}
39+
resolve();
40+
});
41+
}))
42+
);
3743
});
3844

3945
describe('test form up', function () {

test/resume_up.test.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,18 @@ before(function () {
6767
});
6868

6969
after(function () {
70-
return fs.promises.unlink(testFilePath)
71-
.catch(err => {
72-
console.log('Resume upload test. Unlink files failed', err);
73-
});
70+
return Promise.all(
71+
[
72+
testFilePath
73+
].map(p => new Promise(resolve => {
74+
fs.unlink(p, err => {
75+
if (err) {
76+
console.log(`unlink ${p} failed`, err);
77+
}
78+
resolve();
79+
});
80+
}))
81+
);
7482
});
7583

7684
// file to upload
@@ -250,7 +258,7 @@ describe('test resume up', function () {
250258
if (mimeType !== undefined) {
251259
putExtra.mimeType = mimeType;
252260
}
253-
const key = 'storage_putFile_test' + Math.floor(Math.random() * 1000);
261+
const key = 'storage_putFile_test' + Math.floor(Math.random() * 100000);
254262

255263
const promises = doAndWrapResultPromises(callback =>
256264
resumeUploader.putFile(
@@ -325,7 +333,7 @@ describe('test resume up', function () {
325333
putExtra.mimeType = mimeType;
326334
}
327335

328-
const key = 'storage_putStream_test' + Math.floor(Math.random() * 1000);
336+
const key = 'storage_putStream_test' + Math.floor(Math.random() * 100000);
329337

330338
const streamSize = 9 * 1024 * 1024;
331339
const {
@@ -425,7 +433,7 @@ describe('test resume up', function () {
425433
}
426434

427435
it(`test resume up#putStream resume; ${msg}`, function () {
428-
const key = 'storage_putStream_resume_test' + Math.floor(Math.random() * 1000);
436+
const key = 'storage_putStream_resume_test' + Math.floor(Math.random() * 100000);
429437

430438
const putExtra = new qiniu.resume_up.PutExtra();
431439
putExtra.resumeRecordFile = path.join(os.tmpdir(), key + '.resume.json');

test/rs.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ describe('test start bucket manager', function () {
522522

523523
// 空间生命周期
524524
describe('test lifeRule', function () {
525-
const ruleName = 'test_rule_name' + Math.floor(Math.random() * 1000);
525+
const ruleName = 'test_rule_name' + Math.floor(Math.random() * 100000);
526526

527527
function testGet (expectItem, otherRespInfo) {
528528
return bucketManager.getBucketLifecycleRule(bucketName)
@@ -734,7 +734,7 @@ describe('test start bucket manager', function () {
734734
});
735735

736736
describe('test events', function () {
737-
const eventName = 'event_test' + Math.floor(Math.random() * 1000);
737+
const eventName = 'event_test' + Math.floor(Math.random() * 100000);
738738

739739
before(function () {
740740
return bucketManager.deleteBucketEvent(

0 commit comments

Comments
 (0)