Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
33f699f8
提交
33f699f8
authored
6月 26, 2017
作者:
Kevin Atkinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
files api: redo tests
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
上级
3f6a7b7b
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
45 行增加
和
54 行删除
+45
-54
t0250-files-api.sh
test/sharness/t0250-files-api.sh
+45
-54
没有找到文件。
test/sharness/t0250-files-api.sh
浏览文件 @
33f699f8
...
...
@@ -10,18 +10,16 @@ test_description="test the unix files api"
test_init_ipfs
# setup files for testing
test_expect_success
"can create some files for testing"
'
FILE1=$(echo foo | ipfs add -q) &&
FILE2=$(echo bar | ipfs add -q) &&
FILE3=$(echo baz | ipfs add -q) &&
FILE9=$(echo zip | ipfs add -q --raw-leaves) &&
mkdir stuff_test &&
create_files
()
{
FILE1
=
$(
echo
foo | ipfs add
"
$@
"
-q
)
&&
FILE2
=
$(
echo
bar | ipfs add
"
$@
"
-q
)
&&
FILE3
=
$(
echo
baz | ipfs add
"
$@
"
-q
)
&&
mkdir
-p
stuff_test
&&
echo
cats
>
stuff_test/a
&&
echo
dogs
>
stuff_test/b
&&
echo
giraffes
>
stuff_test/c
&&
DIR1=$(ipfs add -q stuff_test | tail -n1)
'
DIR1
=
$(
ipfs add
-
r
"
$@
"
-
q
stuff_test | tail
-n1
)
}
verify_path_exists
()
{
# simply running ls on a file should be a good 'check'
...
...
@@ -91,6 +89,8 @@ test_sharding() {
}
test_files_api
()
{
ROOT_HASH
=
$1
test_expect_success
"can mkdir in root"
'
ipfs files mkdir /cats
'
...
...
@@ -160,6 +160,12 @@ test_files_api() {
verify_dir_contents /cats file1
'
test_expect_success
"file has correct hash and size in directory"
'
echo "file1 $FILE1 4" > ls_l_expected &&
ipfs files ls -l /cats > ls_l_actual &&
test_cmp ls_l_expected ls_l_actual
'
test_expect_success
"can read file"
'
ipfs files read /cats/file1 > file1out
'
...
...
@@ -253,42 +259,6 @@ test_files_api() {
test_cmp roothash roothashafter
'
# test raw node
test_expect_success
"can put a raw-node into root"
'
ipfs files cp /ipfs/$FILE9 /file9
'
test_expect_success
"file shows up in root"
'
verify_dir_contents / file9 cats
'
test_expect_success
"can read file"
'
ipfs files read /file9 > file9out
'
test_expect_success
"output looks good"
'
echo zip > expected &&
test_cmp expected file9out
'
test_expect_success
"can remove file from root"
'
ipfs files rm /file9
'
test_expect_success
"file no longer appears"
'
verify_dir_contents / cats
'
test_expect_success
"check root hash"
'
ipfs files stat --hash / > roothash
'
test_expect_success
"check root hash was not changed"
'
ipfs files stat --hash / > roothashafter &&
test_cmp roothash roothashafter
'
# test read options
test_expect_success
"read from offset works"
'
...
...
@@ -439,7 +409,7 @@ test_files_api() {
test_expect_success
"root hash not bubbled up yet"
'
test -z "$ONLINE" ||
(ipfs refs local > refsout &&
test_expect_code 1 grep
QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt
refsout)
test_expect_code 1 grep
$ROOT_HASH
refsout)
'
test_expect_success
"changes bubbled up to root on inspection"
'
...
...
@@ -447,7 +417,7 @@ test_files_api() {
'
test_expect_success
"root hash looks good"
'
export EXP_ROOT_HASH="
QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt
" &&
export EXP_ROOT_HASH="
$ROOT_HASH
" &&
echo $EXP_ROOT_HASH > root_hash_exp &&
test_cmp root_hash_exp root_hash
'
...
...
@@ -558,26 +528,47 @@ test_files_api() {
ipfs files rm -r /foobar &&
ipfs files rm -r /adir
'
test_expect_success
"root mfs entry is empyt"
'
verify_dir_contents /
'
test_expect_success
"repo gc"
'
ipfs repo gc
'
}
# test offline and online
test_files_api
test_expect_success
"can create some files for testing"
'
create_files
'
test_files_api QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt
test_expect_success
"c
lean up objects from previous test run
"
'
ipfs repo gc
test_expect_success
"c
an create some files for testing with raw-leaves
"
'
create_files --raw-leaves
'
test_files_api QmTpKiKcAj4sbeesN6vrs5w3QeVmd4QmGpxRL81hHut4dZ
test_launch_ipfs_daemon
test_launch_ipfs_daemon
--offline
ONLINE
=
1
# set online flag so tests can easily tell
test_files_api
test_kill_ipfs_daemon
test_expect_success
"can create some files for testing"
'
create_files
'
test_files_api QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt
test_expect_success
"can create some files for testing with raw-leaves"
'
create_files --raw-leaves
'
test_files_api QmTpKiKcAj4sbeesN6vrs5w3QeVmd4QmGpxRL81hHut4dZ
test_kill_ipfs_daemon
--offline
test_expect_success
"enable sharding in config"
'
ipfs config --json Experimental.ShardingEnabled true
'
test_launch_ipfs_daemon
test_launch_ipfs_daemon
--offline
test_sharding
test_kill_ipfs_daemon
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论