Skip to content

Commit

Permalink
fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
lihsai0 committed Mar 4, 2024
1 parent 198a197 commit 33b8277
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
20 changes: 13 additions & 7 deletions test/form_up.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ before(function () {
});

after(function () {
return Promise.all([
fs.promises.unlink(testFilePath1),
fs.promises.unlink(testFilePath2)
])
.catch(err => {
console.log('Form upload test. Unlink files failed', err);
});
return Promise.all(
[
testFilePath1,
testFilePath2
].map(p => new Promise(resolve => {
fs.unlink(p, err => {
if (err) {
console.log(`unlink ${p} failed`, err);
}
resolve();
});
}))
);
});

describe('test form up', function () {
Expand Down
22 changes: 15 additions & 7 deletions test/resume_up.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,18 @@ before(function () {
});

after(function () {
return fs.promises.unlink(testFilePath)
.catch(err => {
console.log('Resume upload test. Unlink files failed', err);
});
return Promise.all(
[
testFilePath
].map(p => new Promise(resolve => {
fs.unlink(p, err => {
if (err) {
console.log(`unlink ${p} failed`, err);
}
resolve();
});
}))
);
});

// file to upload
Expand Down Expand Up @@ -250,7 +258,7 @@ describe('test resume up', function () {
if (mimeType !== undefined) {
putExtra.mimeType = mimeType;
}
const key = 'storage_putFile_test' + Math.floor(Math.random() * 1000);
const key = 'storage_putFile_test' + Math.floor(Math.random() * 100000);

const promises = doAndWrapResultPromises(callback =>
resumeUploader.putFile(
Expand Down Expand Up @@ -325,7 +333,7 @@ describe('test resume up', function () {
putExtra.mimeType = mimeType;
}

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

const streamSize = 9 * 1024 * 1024;
const {
Expand Down Expand Up @@ -425,7 +433,7 @@ describe('test resume up', function () {
}

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

const putExtra = new qiniu.resume_up.PutExtra();
putExtra.resumeRecordFile = path.join(os.tmpdir(), key + '.resume.json');
Expand Down
4 changes: 2 additions & 2 deletions test/rs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ describe('test start bucket manager', function () {

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

function testGet (expectItem, otherRespInfo) {
return bucketManager.getBucketLifecycleRule(bucketName)
Expand Down Expand Up @@ -734,7 +734,7 @@ describe('test start bucket manager', function () {
});

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

before(function () {
return bucketManager.deleteBucketEvent(
Expand Down

0 comments on commit 33b8277

Please sign in to comment.