Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
b85bea9e
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
b85bea9e
编写于
4月 12, 2023
作者:
O
openharmony_ci
提交者:
Gitee
4月 12, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8415 Add async xts codes for moveDir of mod_fs
Merge pull request !8415 from 潘钦旭/xts_movedir
上级
9f742915
161bbb96
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
923 addition
and
0 deletion
+923
-0
storage/storagefileiov9jstest/src/main/js/test/List.test.js
storage/storagefileiov9jstest/src/main/js/test/List.test.js
+2
-0
storage/storagefileiov9jstest/src/main/js/test/members/moveDir.test.js
...gefileiov9jstest/src/main/js/test/members/moveDir.test.js
+921
-0
未找到文件。
storage/storagefileiov9jstest/src/main/js/test/List.test.js
浏览文件 @
b85bea9e
...
...
@@ -26,6 +26,7 @@ import fileIOListfile from './members/listFile.test.js'
import
fileIOLstat
from
'
./members/lstat.test.js
'
import
fileIOMkdir
from
'
./members/mkdir.test.js
'
import
fileIOMkdtemp
from
'
./members/mkdtemp.test.js
'
import
fileIOMoveDir
from
'
./members/moveDir.test.js
'
import
fileIOMoveFile
from
'
./members/moveFile.test.js
'
import
fileIOOpen
from
'
./members/open.test.js
'
import
fileIORead
from
'
./members/read.test.js
'
...
...
@@ -56,6 +57,7 @@ export default function testsuite() {
fileIOLstat
()
fileIOMkdir
()
fileIOMkdtemp
()
fileIOMoveDir
()
fileIOMoveFile
()
fileIOOpen
()
fileIORead
()
...
...
storage/storagefileiov9jstest/src/main/js/test/members/moveDir.test.js
0 → 100755
浏览文件 @
b85bea9e
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
{
fileIO
,
FILE_CONTENT
,
prepareFile
,
nextFileName
,
describe
,
it
,
expect
,
randomString
}
from
'
../Common
'
;
export
default
function
fileIOMoveDir
()
{
describe
(
'
fileIO_fs_moveDir
'
,
function
()
{
const
DIRMODE_DIRECTORY_THROW_ERR
=
0
;
const
DIRMODE_FILE_THROW_ERR
=
1
;
const
DIRMODE_FILE_REPLACE
=
2
;
const
DIRMODE_DIRECTORY_REPLACE
=
3
;
let
readyFiles
=
async
(
testNum
)
=>
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/
'
+
testNum
;
try
{
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
ddpath2
=
dpath
+
'
/destDir
'
;
let
dddpath1
=
ddpath1
+
'
/srcDir_first
'
;
let
dddpath2
=
ddpath2
+
'
/srcDir
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
let
fpath2
=
ddpath1
+
'
/srcFile_first_02
'
;
let
fpath3
=
dddpath2
+
'
/srcFile_first_01
'
;
let
fpath4
=
dddpath2
+
'
/destFile_second_01
'
;
let
ffpath1
=
dddpath1
+
'
/srcFile_second_01
'
;
let
ffpath2
=
dddpath1
+
'
/srcFile_second_02
'
;
let
ddddpath1
=
dddpath1
+
'
/srcDir_second
'
;
let
ddddpath2
=
dddpath2
+
'
/srcDir_first
'
;
let
fffpath1
=
ddddpath1
+
'
/srcFile_third_01
'
;
let
fffpath2
=
ddddpath1
+
'
/srcFile_third_02
'
;
let
fffpath3
=
ddddpath2
+
'
/srcFile_second_01
'
;
let
fffpath4
=
ddddpath2
+
'
/destFile_third_01
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath1
);
fileIO
.
mkdirSync
(
dddpath2
);
fileIO
.
mkdirSync
(
ddddpath1
);
fileIO
.
mkdirSync
(
ddddpath2
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
expect
(
prepareFile
(
fpath2
,
randomString
(
15
))).
assertTrue
();
expect
(
prepareFile
(
fpath3
,
randomString
(
20
))).
assertTrue
();
expect
(
prepareFile
(
fpath4
,
randomString
(
25
))).
assertTrue
();
expect
(
prepareFile
(
ffpath1
,
randomString
(
30
))).
assertTrue
();
expect
(
prepareFile
(
ffpath2
,
randomString
(
35
))).
assertTrue
();
expect
(
prepareFile
(
fffpath1
,
randomString
(
40
))).
assertTrue
();
expect
(
prepareFile
(
fffpath2
,
randomString
(
45
))).
assertTrue
();
expect
(
prepareFile
(
fffpath3
,
randomString
(
50
))).
assertTrue
();
expect
(
prepareFile
(
fffpath4
,
randomString
(
55
))).
assertTrue
();
return
{
baseDir
:
dpath
,
srcDir
:
ddpath1
,
destDir
:
ddpath2
};
}
catch
(
e
)
{
console
.
log
(
testNum
+
'
failed to readyFiles for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
return
{
baseDir
:
dpath
,
srcDir
:
null
,
destDir
:
null
}
}
}
/**
* @tc.number SUB_DF_FILEIO_MOVEDIR_ASYNC_0000
* @tc.name fileIO_test_moveDir_async_000
* @tc.desc Test moveDir() interface.Promise.
* There is no target folder(src) under path dest.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_000
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_moveDir_async_000
'
;
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
ddpath2
=
dpath
+
'
/destDir
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
let
fpath2
=
ddpath1
+
'
/srcFile_first_02
'
;
let
dddpath
=
ddpath1
+
'
/srcDir_first
'
;
let
ffpath1
=
dddpath
+
'
/srcFile_second_01
'
;
let
ffpath2
=
dddpath
+
'
/srcFile_second_02
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
expect
(
prepareFile
(
fpath2
,
randomString
(
15
))).
assertTrue
();
expect
(
prepareFile
(
ffpath1
,
randomString
(
20
))).
assertTrue
();
expect
(
prepareFile
(
ffpath2
,
randomString
(
25
))).
assertTrue
();
try
{
let
stat1
=
fileIO
.
statSync
(
fpath1
);
let
stat2
=
fileIO
.
statSync
(
ffpath1
);
await
fileIO
.
moveDir
(
ddpath1
,
ddpath2
);
expect
(
fileIO
.
accessSync
(
ddpath1
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
ddpath2
+
'
/srcDir/srcFile_first_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
ddpath2
+
'
/srcDir/srcDir_first/srcFile_second_01
'
)).
assertTrue
();
let
stat3
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
==
stat3
.
size
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
==
stat4
.
size
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIR_ASYNC_0100
* @tc.name fileIO_test_moveDir_async_001
* @tc.desc Test moveDir() interface.Callback.
* There is no target folder(src) under path dest.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_001
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_moveDir_async_001
'
;
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
ddpath2
=
dpath
+
'
/destDir
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
let
fpath2
=
ddpath1
+
'
/srcFile_first_02
'
;
let
dddpath
=
ddpath1
+
'
/srcDir_first
'
;
let
ffpath1
=
dddpath
+
'
/srcFile_second_01
'
;
let
ffpath2
=
dddpath
+
'
/srcFile_second_02
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
expect
(
prepareFile
(
fpath2
,
randomString
(
15
))).
assertTrue
();
expect
(
prepareFile
(
ffpath1
,
randomString
(
20
))).
assertTrue
();
expect
(
prepareFile
(
ffpath2
,
randomString
(
25
))).
assertTrue
();
try
{
let
stat1
=
fileIO
.
statSync
(
fpath1
);
let
stat2
=
fileIO
.
statSync
(
ffpath1
);
fileIO
.
moveDir
(
ddpath1
,
ddpath2
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_moveDir_async_001 err package
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
fileIO
.
accessSync
(
ddpath1
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
ddpath2
+
'
/srcDir/srcFile_first_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
ddpath2
+
'
/srcDir/srcDir_first/srcFile_second_01
'
)).
assertTrue
();
let
stat3
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
==
stat3
.
size
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
==
stat4
.
size
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
);
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIR_ASYNC_0200
* @tc.name fileIO_test_moveDir_async_002
* @tc.desc Test moveDir() interface.Promise.
* There is a target folder(src) under path dest but it is empty.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_002
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_moveDir_async_002
'
;
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
ddpath2
=
dpath
+
'
/destDir
'
;
let
dddpath2
=
ddpath2
+
'
/srcDir
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
let
fpath2
=
ddpath1
+
'
/srcFile_first_02
'
;
let
dddpath1
=
ddpath1
+
'
/srcDir_first
'
;
let
ffpath1
=
dddpath1
+
'
/srcFile_second_01
'
;
let
ffpath2
=
dddpath1
+
'
/srcFile_second_02
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath1
);
fileIO
.
mkdirSync
(
dddpath2
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
expect
(
prepareFile
(
fpath2
,
randomString
(
15
))).
assertTrue
();
expect
(
prepareFile
(
ffpath1
,
randomString
(
20
))).
assertTrue
();
expect
(
prepareFile
(
ffpath2
,
randomString
(
25
))).
assertTrue
();
try
{
let
stat1
=
fileIO
.
statSync
(
fpath1
);
let
stat2
=
fileIO
.
statSync
(
ffpath1
);
await
fileIO
.
moveDir
(
ddpath1
,
ddpath2
);
expect
(
fileIO
.
accessSync
(
ddpath1
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
ddpath2
+
'
/srcDir/srcFile_first_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
ddpath2
+
'
/srcDir/srcDir_first/srcFile_second_01
'
)).
assertTrue
();
let
stat3
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
==
stat3
.
size
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
==
stat4
.
size
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_002 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIR_ASYNC_0300
* @tc.name fileIO_test_moveDir_async_003
* @tc.desc Test moveDir() interface.Callback.
* There is a target folder(src) under path dest but it is empty.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_003
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_moveDir_async_003
'
;
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
ddpath2
=
dpath
+
'
/destDir
'
;
let
dddpath2
=
ddpath2
+
'
/srcDir
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
let
fpath2
=
ddpath1
+
'
/srcFile_first_02
'
;
let
dddpath1
=
ddpath1
+
'
/srcDir_first
'
;
let
ffpath1
=
dddpath1
+
'
/srcFile_second_01
'
;
let
ffpath2
=
dddpath1
+
'
/srcFile_second_02
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath1
);
fileIO
.
mkdirSync
(
dddpath2
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
expect
(
prepareFile
(
fpath2
,
randomString
(
15
))).
assertTrue
();
expect
(
prepareFile
(
ffpath1
,
randomString
(
20
))).
assertTrue
();
expect
(
prepareFile
(
ffpath2
,
randomString
(
25
))).
assertTrue
();
try
{
let
stat1
=
fileIO
.
statSync
(
fpath1
);
let
stat2
=
fileIO
.
statSync
(
ffpath1
);
fileIO
.
moveDir
(
ddpath1
,
ddpath2
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_moveDir_async_003 err package
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
fileIO
.
accessSync
(
ddpath1
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
ddpath2
+
'
/srcDir/srcFile_first_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
ddpath2
+
'
/srcDir/srcDir_first/srcFile_second_01
'
)).
assertTrue
();
let
stat3
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
==
stat3
.
size
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
==
stat4
.
size
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
);
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_003 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIR_ASYNC_0400
* @tc.name fileIO_test_moveDir_async_004
* @tc.desc Test moveFile() interface.Promise.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_DIRECTORY_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_004
'
,
0
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_004
'
);
try
{
let
stat1
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcFile_first_01
'
);
let
stat2
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcDir_first/srcFile_second_01
'
);
let
dirent1
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent1
.
length
==
4
).
assertTrue
();
await
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
destDir
,
DIRMODE_DIRECTORY_REPLACE
);
expect
(
fileIO
.
accessSync
(
dpath
.
srcDir
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/destFile_second_01
'
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/destFile_third_01
'
)).
assertFalse
();
let
stat3
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
==
stat3
.
size
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
==
stat4
.
size
).
assertTrue
();
let
dirent2
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent2
.
length
==
6
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_004 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIR_ASYNC_0500
* @tc.name fileIO_test_moveDir_async_005
* @tc.desc Test moveFile() interface.Callback.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_DIRECTORY_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_005
'
,
0
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_005
'
);
try
{
let
stat1
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcFile_first_01
'
);
let
stat2
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcDir_first/srcFile_second_01
'
);
let
dirent1
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent1
.
length
==
4
).
assertTrue
();
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
destDir
,
DIRMODE_DIRECTORY_REPLACE
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_moveDir_async_005 err package
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
fileIO
.
accessSync
(
dpath
.
srcDir
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/destFile_second_01
'
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/destFile_third_01
'
)).
assertFalse
();
let
stat3
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
==
stat3
.
size
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
==
stat4
.
size
).
assertTrue
();
let
dirent2
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent2
.
length
==
6
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_005 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIR_ASYNC_0600
* @tc.name fileIO_test_moveDir_async_006
* @tc.desc Test moveFile() interface.Promise.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_FILE_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_006
'
,
0
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_006
'
);
try
{
let
stat1
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
let
stat2
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
let
dirent1
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent1
.
length
==
4
).
assertTrue
();
await
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
destDir
,
DIRMODE_FILE_REPLACE
);
expect
(
fileIO
.
accessSync
(
dpath
.
srcDir
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/destFile_second_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/destFile_third_01
'
)).
assertTrue
();
let
stat3
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
!=
stat3
.
size
&&
stat3
.
size
==
10
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
!=
stat4
.
size
&&
stat4
.
size
==
30
).
assertTrue
();
let
dirent2
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent2
.
length
==
8
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_006 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIR_ASYNC_0700
* @tc.name fileIO_test_moveDir_async_007
* @tc.desc Test moveFile() interface.Callback.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_FILE_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_007
'
,
0
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_007
'
);
try
{
let
stat1
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
let
stat2
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
let
dirent1
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent1
.
length
==
4
).
assertTrue
();
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
destDir
,
DIRMODE_FILE_REPLACE
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_moveDir_async_007 err package
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
fileIO
.
accessSync
(
dpath
.
srcDir
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/destFile_second_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/destFile_third_01
'
)).
assertTrue
();
let
stat3
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
!=
stat3
.
size
&&
stat3
.
size
==
10
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
!=
stat4
.
size
&&
stat4
.
size
==
30
).
assertTrue
();
let
dirent2
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent2
.
length
==
8
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_007 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_0800
* @tc.name fileIO_test_moveDir_async_008
* @tc.desc Test moveFile() interface.Promise.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_FILE_THROW_ERR.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_008
'
,
0
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_008
'
);
try
{
let
dirnet1
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirnet1
.
length
==
4
).
assertTrue
();
await
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
destDir
,
DIRMODE_FILE_THROW_ERR
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
log
(
'
fileIO_test_moveDir_async_008 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
let
stat1
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcFile_first_01
'
);
let
stat2
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcDir_first/srcFile_second_01
'
);
let
stat3
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
!=
stat3
.
size
&&
stat3
.
size
==
20
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
!=
stat4
.
size
&&
stat4
.
size
==
50
).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_02
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_02
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/destFile_second_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/destFile_third_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
)).
assertTrue
();
let
dirent2
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent2
.
length
==
8
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
expect
(
err
.
code
==
13900015
&&
err
.
message
==
'
File exists
'
).
assertTrue
();
expect
(
err
.
data
.
length
==
2
).
assertTrue
();
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_0900
* @tc.name fileIO_test_moveDir_async_009
* @tc.desc Test moveFile() interface.Callback.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_FILE_THROW_ERR.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_009
'
,
0
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_009
'
);
try
{
let
dirent1
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent1
.
length
==
4
).
assertTrue
();
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
destDir
,
DIRMODE_FILE_THROW_ERR
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_moveDir_async_009 error:
'
+
JSON
.
stringify
(
err
));
let
stat1
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcFile_first_01
'
);
let
stat2
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcDir_first/srcFile_second_01
'
);
let
stat3
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
!=
stat3
.
size
&&
stat3
.
size
==
20
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
!=
stat4
.
size
&&
stat4
.
size
==
50
).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_02
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_02
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/destFile_second_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/destFile_third_01
'
)).
assertTrue
();
let
dirent2
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent2
.
length
==
8
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
expect
(
err
.
code
==
13900015
&&
err
.
message
==
'
File exists
'
).
assertTrue
();
expect
(
err
.
data
.
length
==
2
).
assertTrue
();
done
();
}
});
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_009 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1000
* @tc.name fileIO_test_moveDir_async_010
* @tc.desc Test moveFile() interface.Promise.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_DIRECTORY_THROW_ERR.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_010
'
,
0
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_010
'
);
try
{
await
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
destDir
,
DIRMODE_DIRECTORY_THROW_ERR
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
console
.
log
(
'
fileIO_test_moveDir_async_010 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900032
&&
e
.
message
==
'
Directory not empty
'
).
assertTrue
();
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1100
* @tc.name fileIO_test_moveDir_async_011
* @tc.desc Test moveFile() interface.Callback.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_DIRECTORY_THROW_ERR.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_011
'
,
0
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_011
'
);
try
{
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
destDir
,
DIRMODE_DIRECTORY_THROW_ERR
,
(
err
)
=>
{
if
(
err
)
{
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
console
.
log
(
'
fileIO_test_moveDir_async_011 error: {message:
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
expect
(
err
.
code
==
13900032
&&
err
.
message
==
'
Directory not empty
'
).
assertTrue
();
done
();
}
});
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_011 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1200
* @tc.name fileIO_test_moveDir_async_012
* @tc.desc Test moveFile() interface.Promise.
* Src is empty and there is a target folder(src) under path dest but it is empty.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_012
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
nextFileName
(
'
fileIO_test_moveDir_async_012
'
);
let
fpath
=
dpath
+
'
/file_006.txt
'
;
let
ddpath
=
dpath
+
'
/dir_006
'
;
let
ddpath2
=
dpath
+
'
/dir2_006
'
;
let
ffpath3
=
ddpath2
+
'
/new.txt
'
;
let
dddpath3
=
ddpath2
+
'
/dir_006
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath3
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
prepareFile
(
ffpath3
,
FILE_CONTENT
)).
assertTrue
();
try
{
await
fileIO
.
moveDir
(
ddpath
,
ddpath2
,
DIRMODE_FILE_REPLACE
);
expect
(
fileIO
.
accessSync
(
ddpath
)).
assertFalse
();
fileIO
.
rmdirSync
(
dpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_012 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1300
* @tc.name fileIO_test_moveDir_async_013
* @tc.desc Test moveFile() interface.Callback.
* Src is empty and there is a target folder(src) under path dest but it is empty.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_013
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
nextFileName
(
'
fileIO_test_moveDir_async_013
'
);
let
fpath
=
dpath
+
'
/file_006.txt
'
;
let
ddpath
=
dpath
+
'
/dir_006
'
;
let
ddpath2
=
dpath
+
'
/dir2_006
'
;
let
ffpath3
=
ddpath2
+
'
/new.txt
'
;
let
dddpath3
=
ddpath2
+
'
/dir_006
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath3
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
prepareFile
(
ffpath3
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileIO
.
moveDir
(
ddpath
,
ddpath2
,
DIRMODE_FILE_REPLACE
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_moveDir_async_013 err package
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
fileIO
.
accessSync
(
ddpath
)).
assertFalse
();
fileIO
.
rmdirSync
(
dpath
);
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_013 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1400
* @tc.name fileIO_test_moveDir_async_014
* @tc.desc Test moveFile() interface.Promise.
* Src is empty and there is no target folder(src) under path dest.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_014
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
nextFileName
(
'
fileIO_test_moveDir_async_014
'
);
let
fpath
=
dpath
+
'
/file_007.txt
'
;
let
ddpath
=
dpath
+
'
/dir_007
'
;
let
ddpath2
=
dpath
+
'
/dir2_007
'
;
let
ffpath3
=
ddpath2
+
'
/new.txt
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath
);
fileIO
.
mkdirSync
(
ddpath2
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
prepareFile
(
ffpath3
,
FILE_CONTENT
)).
assertTrue
();
try
{
await
fileIO
.
moveDir
(
ddpath
,
ddpath2
,
DIRMODE_FILE_REPLACE
);
expect
(
fileIO
.
accessSync
(
ddpath
)).
assertFalse
();
fileIO
.
rmdirSync
(
dpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_014 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1500
* @tc.name fileIO_test_moveDir_async_015
* @tc.desc Test moveFile() interface.CallBack.
* Src is empty and there is no target folder(src) under path dest.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_015
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
nextFileName
(
'
fileIO_test_moveDir_async_015
'
);
let
fpath
=
dpath
+
'
/file_007.txt
'
;
let
ddpath
=
dpath
+
'
/dir_007
'
;
let
ddpath2
=
dpath
+
'
/dir2_007
'
;
let
ffpath3
=
ddpath2
+
'
/new.txt
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath
);
fileIO
.
mkdirSync
(
ddpath2
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
prepareFile
(
ffpath3
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileIO
.
moveDir
(
ddpath
,
ddpath2
,
DIRMODE_FILE_REPLACE
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_moveDir_async_015 err package
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
expect
(
fileIO
.
accessSync
(
ddpath
)).
assertFalse
();
fileIO
.
rmdirSync
(
dpath
);
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_015 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1600
* @tc.name fileIO_test_moveDir_async_016
* @tc.desc Test moveFile() interface.Promise.
* Invalid mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_016
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_016
'
);
try
{
const
INVALIDE_MODE
=
-
1
;
await
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
destDir
,
INVALIDE_MODE
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
console
.
log
(
'
fileIO_test_moveDir_async_016 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
expect
(
err
.
code
==
13900020
&&
err
.
message
==
'
Invalid argument
'
).
assertTrue
();
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1700
* @tc.name fileIO_test_moveDir_async_017
* @tc.desc Test moveFile() interface.Callback.
* Invalid mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_017
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_017
'
);
try
{
const
INVALIDE_MODE
=
4
;
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
destDir
,
INVALIDE_MODE
,
(
err
)
=>
{
expect
(
false
).
assertTrue
();
});
}
catch
(
e
)
{
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
console
.
log
(
'
fileIO_test_moveDir_async_017 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1800
* @tc.name fileIO_test_moveDir_async_018
* @tc.desc Test moveFile() interface.Promise.
* Invalid path.The path point to a file, not a directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_018
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_018
'
);
try
{
await
fileIO
.
moveDir
(
dpath
.
srcDir
+
'
/srcFile_first_01
'
,
dpath
.
destDir
+
'
srcDir/srcFile_first_01
'
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
console
.
log
(
'
fileIO_test_moveDir_async_018 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1900
* @tc.name fileIO_test_moveDir_async_019
* @tc.desc Test moveFile() interface.Callback.
* Invalid path.The path point to a file, not a directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_019
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_019
'
);
try
{
fileIO
.
moveDir
(
dpath
.
srcDir
+
'
/srcFile_first_01
'
,
dpath
.
destDir
+
'
srcDir/srcFile_first_01
'
,
(
err
)
=>
{
expect
(
false
).
assertTrue
();
});
}
catch
(
e
)
{
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
console
.
log
(
'
fileIO_test_moveDir_async_019 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_2000
* @tc.name fileIO_test_moveDir_async_020
* @tc.desc Test moveFile() interface.Promise.
* Invalid path. Can not move the same path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_020
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_020
'
);
try
{
await
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
srcDir
,
DIRMODE_FILE_THROW_ERR
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
console
.
log
(
'
fileIO_test_moveDir_async_020 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_2100
* @tc.name fileIO_test_moveDir_async_021
* @tc.desc Test moveFile() interface.Callback.
* Invalid path.Can not move the same path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_021
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_021
'
);
try
{
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
srcDir
,
DIRMODE_FILE_THROW_ERR
,
(
err
)
=>
{
if
(
err
)
{
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
console
.
log
(
'
fileIO_test_moveDir_async_021 error: {message:
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
expect
(
err
.
code
==
13900020
&&
err
.
message
==
'
Invalid argument
'
).
assertTrue
();
done
();
}
});
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_021 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_2200
* @tc.name fileIO_test_moveDir_async_022
* @tc.desc Test moveFile() interface.Promise.
* Invalid path. Can not move subPath.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_022
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_023
'
);
try
{
await
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
srcDir
+
'
/srcDir_first
'
,
DIRMODE_FILE_THROW_ERR
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
console
.
log
(
'
fileIO_test_moveDir_async_022 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_2300
* @tc.name fileIO_test_moveDir_async_023
* @tc.desc Test moveFile() interface.Callback.
* Invalid path.Can not move subPath.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_async_023
'
,
3
,
async
function
(
done
)
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_023
'
);
try
{
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
srcDir
+
'
/srcDir_first
'
,
DIRMODE_FILE_THROW_ERR
,
(
err
)
=>
{
if
(
err
)
{
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
console
.
log
(
'
fileIO_test_moveDir_async_023 error: {message:
'
+
err
.
message
+
'
, code:
'
+
err
.
code
+
'
}
'
);
expect
(
err
.
code
==
13900020
&&
err
.
message
==
'
Invalid argument
'
).
assertTrue
();
done
();
}
});
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_async_023 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
});
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录