未验证 提交 8c29313a 编写于 作者: O openharmony_ci 提交者: Gitee

!3571 刪除fileio重复用例以及冗余代码、注释规范修改

Merge pull request !3571 from zhangxingxia/OpenHarmony-3.1-Release
...@@ -15,24 +15,19 @@ ...@@ -15,24 +15,19 @@
import { import {
fileio, fileio,
FILE_CONTENT,
prepareFile,
nextFileName, nextFileName,
isIntNum,
isString,
isBoolean,
describe, describe,
it, it,
expect, expect,
} from '../../Common'; } from '../../Common';
describe('fileio_dir_close_read', function () { describe('fileio_dir_close', function () {
/** /**
* @tc.number SUB_DF_FILEIO_DIR_CLOSE_ASYNC_0000 * @tc.number SUB_DF_FILEIO_DIR_CLOSE_ASYNC_0000
* @tc.name fileio_test_dir_close_async_000 * @tc.name fileio_test_dir_close_async_000
* @tc.desc Test Dir.closeAsync() interface. * @tc.desc Test Dir close() interface,return in promise mode.
* @tc.size MEDIUM(中型) * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
* @tc.require * @tc.require
...@@ -41,37 +36,63 @@ describe('fileio_dir_close_read', function () { ...@@ -41,37 +36,63 @@ describe('fileio_dir_close_read', function () {
let dpath = await nextFileName('fileio_test_dir_close_async_000') + 'd'; let dpath = await nextFileName('fileio_test_dir_close_async_000') + 'd';
try { try {
expect(fileio.mkdirSync(dpath) == null).assertTrue(); fileio.mkdirSync(dpath);
let dd = await fileio.opendir(dpath); let dd = await fileio.opendir(dpath);
expect(dd !== null).assertTrue(); await dd.close();
expect((await dd.close()) == null).assertTrue(); fileio.rmdirSync(dpath);
expect(fileio.rmdirSync(dpath) == null).assertTrue();
done(); done();
} catch (e) { } catch (e) {
console.log('fileio_test_dir_close_async_000 has failed for ' + e); console.info('fileio_test_dir_close_async_000 has failed for ' + e);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
/** /**
* @tc.number SUB_DF_FileIO_Dir_close_Async_0001 * @tc.number SUB_DF_FileIO_Dir_close_Async_0100
* @tc.name fileio_test_dir_close_async_001 * @tc.name fileio_test_dir_close_async_001
* @tc.desc Test Dir.closeAsync() interface. * @tc.desc Test Dir close() interface,return in callback mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/ */
it('fileio_test_dir_close_async_001', 0, async function (done) { it('fileio_test_dir_close_async_001', 0, async function (done) {
let dpath = await nextFileName('fileio_test_dir_close_async_001') + 'd'; let dpath = await nextFileName('fileio_test_dir_close_async_001') + 'd';
try { try {
expect(fileio.mkdirSync(dpath) == null).assertTrue(); fileio.mkdirSync(dpath);
let dd = await fileio.opendir(dpath); let dd = await fileio.opendir(dpath);
expect(dd !== null).assertTrue();
dd.close(function (err) { dd.close(function (err) {
expect(fileio.rmdirSync(dpath) == null).assertTrue(); fileio.rmdirSync(dpath);
done(); done();
}); });
} catch (e) { } catch (e) {
console.log('fileio_test_dir_close_async_001 has failed for ' + e); console.info('fileio_test_dir_close_async_001 has failed for ' + e);
expect(null).assertFail(); expect(null).assertFail();
} }
}); });
/**
* @tc.number SUB_DF_FileIO_Dir_close_Async_0200
* @tc.name fileio_test_dir_close_async_002
* @tc.desc Test Dir close() interface,there are multiple parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_dir_close_async_002', 0, async function (done) {
let dpath = await nextFileName('fileio_test_dir_close_async_002') + 'd';
try {
fileio.mkdirSync(dpath);
let dd = await fileio.opendir(dpath);
dd.close(-1,function (err) {
});
} catch (e) {
console.info('fileio_test_dir_close_async_002 has failed for ' + e);
expect(e.message == "Number of arguments unmatched").assertTrue();
fileio.rmdirSync(dpath);
done();
}
});
}); });
...@@ -20,47 +20,69 @@ import { ...@@ -20,47 +20,69 @@ import {
describe('fileio_close', function () { describe('fileio_close', function () {
/** /**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0000 * @tc.number SUB_DF_FILEIO_CLOSESYNC_0000
* @tc.name fileio_test_close_sync_000 * @tc.name fileio_test_close_sync_000
* @tc.desc Test closeSync() interfaces * @tc.desc Test closeSync() interfaces
* @tc.size MEDIUM(中型) * @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it('fileio_test_close_sync_000', 0,async function () {
let fpath = await nextFileName('fileio_test_close_async_000');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try {
let fd = fileio.openSync(fpath, 0o102, 0o666);
fileio.closeSync(fd);
fileio.unlinkSync(fpath);
} catch (e) {
console.info('fileio_test_close_sync_000 has failed for ' + e);
}
})
/**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0100
* @tc.name fileio_test_close_sync_001
* @tc.desc Test closeSync() interfaces,No parameters.
* @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
* @tc.require * @tc.require
*/ */
it('fileio_test_close_sync_000', 0, function () { it('fileio_test_close_sync_001', 0, function () {
try { try {
fileio.closeSync(); fileio.closeSync();
expect(null).assertFail();
} catch (e) { } catch (e) {
console.log('fileio_test_close_sync_000 has failed for ' + e); console.info('fileio_test_close_sync_001 has failed for ' + e);
expect(e.message == 'Number of arguments unmatched').assertTrue();
} }
}) })
/** /**
* @tc.number SUB_DF_FILEIO_CLOSESYNC_0010 * @tc.number SUB_DF_FILEIO_CLOSESYNC_0010
* @tc.name fileio_test_close_sync_001 * @tc.name fileio_test_close_sync_001
* @tc.desc Test closeSync() interfaces * @tc.desc Test closeSync() interfaces,fd is illegal.
* @tc.size MEDIUM(中型) * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
* @tc.require * @tc.require
*/ */
it('fileio_test_close_sync_001', 0, function () { it('fileio_test_close_sync_002', 0, function () {
try { try {
fileio.closeSync(-1); fileio.closeSync(-1);
expect(null).assertFail();
} catch (e) { } catch (e) {
console.log('fileio_test_close_sync_001 has failed for ' + e); console.info('fileio_test_close_sync_002 has failed for ' + e);
expect(e.message == 'Bad file descriptor').assertTrue();
} }
}) })
/** /**
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0000 * @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0000
* @tc.name fileio_test_close_async_000 * @tc.name fileio_test_close_async_000
* @tc.desc Test close() interfaces * @tc.desc Test close() interfaces,return in callback mode.
* @tc.size MEDIUM(中型) * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
* @tc.require * @tc.require
...@@ -72,11 +94,11 @@ describe('fileio_close', function () { ...@@ -72,11 +94,11 @@ describe('fileio_close', function () {
try { try {
let fd = fileio.openSync(fpath, 0o102, 0o666); let fd = fileio.openSync(fpath, 0o102, 0o666);
fileio.close(fd, function (err) { fileio.close(fd, function (err) {
expect(fileio.unlinkSync(fpath) == null).assertTrue(); fileio.unlinkSync(fpath);
done(); done();
}); });
} catch (e) { } catch (e) {
console.log('fileio_test_close_async_000 has failed for ' + e); console.info('fileio_test_close_async_000 has failed for ' + e);
expect(null).assertFail(); expect(null).assertFail();
} }
}) })
...@@ -84,8 +106,8 @@ describe('fileio_close', function () { ...@@ -84,8 +106,8 @@ describe('fileio_close', function () {
/** /**
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0010 * @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0010
* @tc.name fileio_test_close_async_001 * @tc.name fileio_test_close_async_001
* @tc.desc Test close() interfaces * @tc.desc Test close() interfaces,return in promise mode.
* @tc.size MEDIUM(中型) * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
* @tc.require * @tc.require
...@@ -96,11 +118,11 @@ describe('fileio_close', function () { ...@@ -96,11 +118,11 @@ describe('fileio_close', function () {
try { try {
let fd = fileio.openSync(fpath, 0o102, 0o666); let fd = fileio.openSync(fpath, 0o102, 0o666);
expect(await fileio.close(fd) == null).assertTrue(); await fileio.close(fd);
expect(fileio.unlinkSync(fpath) == null).assertTrue(); fileio.unlinkSync(fpath);
done(); done();
} catch (e) { } catch (e) {
console.log('fileio_test_close_async_001 has failed for ' + e); console.info('fileio_test_close_async_001 has failed for ' + e);
expect(null).assertFail(); expect(null).assertFail();
} }
}) })
...@@ -108,20 +130,25 @@ describe('fileio_close', function () { ...@@ -108,20 +130,25 @@ describe('fileio_close', function () {
/** /**
* @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0020 * @tc.number SUB_DF_FILEIO_CLOSE_ASYNC_0020
* @tc.name fileio_test_close_async_002 * @tc.name fileio_test_close_async_002
* @tc.desc Test close() interfaces * @tc.desc Test close() interfaces,there are multiple parameters.
* @tc.size MEDIUM(中型) * @tc.size MEDIUM
* @tc.type Function * @tc.type Function
* @tc.level Level 0 * @tc.level Level 0
* @tc.require * @tc.require
*/ */
it('fileio_test_close_async_002', 0, async function (done) { it('fileio_test_close_async_002', 0, async function (done) {
let fpath = await nextFileName('fileio_test_close_async_001');
expect(prepareFile(fpath, FILE_CONTENT)).assertTrue();
try { try {
await fileio.close(-1); let fd = fileio.openSync(fpath, 0o102, 0o666);
expect(null).assertFail(); fileio.close(fd, 2,function (err) {
done(); });
} catch (e) { } catch (e) {
expect(!!e).assertTrue(); console.info('fileio_test_close_async_002 has failed for ' + e);
console.log('fileio_test_close_async_002 has failed for ' + e); expect(e.message == "Number of arguments unmatched").assertTrue();
fileio.unlinkSync(fpath);
done(); done();
} }
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册