Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
220b9d22
提交
220b9d22
authored
10月 03, 2015
作者:
rht
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move test add cat offline into t0040
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
上级
5b2d2ebd
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
154 行增加
和
186 行删除
+154
-186
t0040-add-and-cat.sh
test/sharness/t0040-add-and-cat.sh
+154
-111
t0041-add-cat-offline.sh
test/sharness/t0041-add-cat-offline.sh
+0
-75
没有找到文件。
test/sharness/t0040-add-and-cat.sh
浏览文件 @
220b9d22
...
@@ -12,6 +12,146 @@ client_err() {
...
@@ -12,6 +12,146 @@ client_err() {
printf
"
$@
\n\n
Use 'ipfs add --help' for information about this command
\n
"
printf
"
$@
\n\n
Use 'ipfs add --help' for information about this command
\n
"
}
}
test_add_cat_file
()
{
test_expect_success
"ipfs add succeeds"
'
echo "Hello Worlds!" >mountdir/hello.txt &&
ipfs add mountdir/hello.txt >actual
'
test_expect_success
"ipfs add output looks good"
'
HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
echo "added $HASH hello.txt" >expected &&
test_cmp expected actual
'
test_expect_success
"ipfs add --only-hash succeeds"
'
ipfs add --only-hash mountdir/hello.txt > oh_actual
'
test_expect_success
"ipfs add --only-hash output looks good"
'
test_cmp expected oh_actual
'
test_expect_success
"ipfs cat succeeds"
'
ipfs cat "$HASH" >actual
'
test_expect_success
"ipfs cat output looks good"
'
echo "Hello Worlds!" >expected &&
test_cmp expected actual
'
test_expect_success
"ipfs cat /ipfs/file succeeds"
'
ipfs cat /ipfs/$HASH >actual
'
test_expect_success
"output looks good"
'
test_cmp expected actual
'
}
test_add_cat_5MB
()
{
test_expect_success
"generate 5MB file using go-random"
'
random 5242880 41 >mountdir/bigfile
'
test_expect_success
"sha1 of the file looks ok"
'
echo "11145620fb92eb5a49c9986b5c6844efda37e471660e" >sha1_expected &&
multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
test_cmp sha1_expected sha1_actual
'
test_expect_success
"'ipfs add bigfile' succeeds"
'
ipfs add mountdir/bigfile >actual
'
test_expect_success
"'ipfs add bigfile' output looks good"
'
HASH="QmSr7FqYkxYWGoSfy8ZiaMWQ5vosb18DQGCzjwEQnVHkTb" &&
echo "added $HASH bigfile" >expected &&
test_cmp expected actual
'
test_expect_success
"'ipfs cat' succeeds"
'
ipfs cat "$HASH" >actual
'
test_expect_success
"'ipfs cat' output looks good"
'
test_cmp mountdir/bigfile actual
'
test_expect_success FUSE
"cat ipfs/bigfile succeeds"
'
cat "ipfs/$HASH" >actual
'
test_expect_success FUSE
"cat ipfs/bigfile looks good"
'
test_cmp mountdir/bigfile actual
'
}
test_add_cat_expensive
()
{
test_expect_success EXPENSIVE
"generate 100MB file using go-random"
'
random 104857600 42 >mountdir/bigfile
'
test_expect_success EXPENSIVE
"sha1 of the file looks ok"
'
echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
test_cmp sha1_expected sha1_actual
'
test_expect_success EXPENSIVE
"ipfs add bigfile succeeds"
'
ipfs add mountdir/bigfile >actual
'
test_expect_success EXPENSIVE
"ipfs add bigfile output looks good"
'
HASH="QmU9SWAPPmNEKZB8umYMmjYvN7VyHqABNvdA6GUi4MMEz3" &&
echo "added $HASH bigfile" >expected &&
test_cmp expected actual
'
test_expect_success EXPENSIVE
"ipfs cat succeeds"
'
ipfs cat "$HASH" | multihash -a=sha1 -e=hex >sha1_actual
'
test_expect_success EXPENSIVE
"ipfs cat output looks good"
'
ipfs cat "$HASH" >actual &&
test_cmp mountdir/bigfile actual
'
test_expect_success EXPENSIVE
"ipfs cat output hashed looks good"
'
echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
test_cmp sha1_expected sha1_actual
'
test_expect_success FUSE,EXPENSIVE
"cat ipfs/bigfile succeeds"
'
cat "ipfs/$HASH" | multihash -a=sha1 -e=hex >sha1_actual
'
test_expect_success FUSE,EXPENSIVE
"cat ipfs/bigfile looks good"
'
test_cmp sha1_expected sha1_actual
'
}
test_add_named_pipe
()
{
err_prefix
=
$1
test_expect_success
"useful error message when adding a named pipe"
'
mkfifo named-pipe &&
test_expect_code 1 ipfs add named-pipe 2>actual &&
client_err "Error: Unrecognized file type for named-pipe: $(generic_stat named-pipe)" >expected &&
rm named-pipe &&
test_cmp expected actual
'
test_expect_success
"useful error message when recursively adding a named pipe"
'
mkdir -p named-pipe-dir &&
mkfifo named-pipe-dir/named-pipe &&
test_expect_code 1 ipfs add -r named-pipe-dir 2>actual &&
printf "Error:$err_prefix Unrecognized file type for named-pipe-dir/named-pipe: $(generic_stat named-pipe-dir/named-pipe)\n" >expected &&
rm named-pipe-dir/named-pipe &&
rmdir named-pipe-dir &&
test_cmp expected actual
'
}
test_launch_ipfs_daemon_and_mount
test_launch_ipfs_daemon_and_mount
test_expect_success
"'ipfs add --help' succeeds"
'
test_expect_success
"'ipfs add --help' succeeds"
'
...
@@ -32,33 +172,7 @@ test_expect_success "'ipfs cat --help' output looks good" '
...
@@ -32,33 +172,7 @@ test_expect_success "'ipfs cat --help' output looks good" '
test_fsh cat actual
test_fsh cat actual
'
'
test_expect_success
"ipfs add succeeds"
'
test_add_cat_file
echo "Hello Worlds!" >mountdir/hello.txt &&
ipfs add mountdir/hello.txt >actual
'
test_expect_success
"ipfs add output looks good"
'
HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
echo "added $HASH hello.txt" >expected &&
test_cmp expected actual
'
test_expect_success
"ipfs add --only-hash succeeds"
'
ipfs add --only-hash mountdir/hello.txt > oh_actual
'
test_expect_success
"ipfs add --only-hash output looks good"
'
ipfs add --only-hash mountdir/hello.txt > oh_actual
'
test_expect_success
"ipfs cat succeeds"
'
ipfs cat "$HASH" >actual
'
test_expect_success
"ipfs cat output looks good"
'
echo "Hello Worlds!" >expected &&
test_cmp expected actual
'
test_expect_success
"ipfs cat succeeds with stdin opened (issue #1141)"
'
test_expect_success
"ipfs cat succeeds with stdin opened (issue #1141)"
'
cat mountdir/hello.txt | while read line; do ipfs cat "$HASH" >actual || exit; done
cat mountdir/hello.txt | while read line; do ipfs cat "$HASH" >actual || exit; done
...
@@ -187,100 +301,29 @@ test_expect_success "ipfs cat output looks good" '
...
@@ -187,100 +301,29 @@ test_expect_success "ipfs cat output looks good" '
test_expect_success
"go-random is installed"
'
test_expect_success
"go-random is installed"
'
type random
type random
'
'
test_expect_success
"generate 5MB file using go-random"
'
test_add_cat_5MB
random 5242880 41 >mountdir/bigfile
'
test_expect_success
"sha1 of the file looks ok"
'
test_add_cat_expensive
echo "11145620fb92eb5a49c9986b5c6844efda37e471660e" >sha1_expected &&
multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
test_cmp sha1_expected sha1_actual
'
test_expect_success
"'ipfs add bigfile' succeeds"
'
ipfs add mountdir/bigfile >actual
'
test_expect_success
"'ipfs add bigfile' output looks good"
'
HASH="QmSr7FqYkxYWGoSfy8ZiaMWQ5vosb18DQGCzjwEQnVHkTb" &&
echo "added $HASH bigfile" >expected &&
test_cmp expected actual
'
test_expect_success
"'ipfs cat' succeeds"
'
ipfs cat "$HASH" >actual
'
test_expect_success
"'ipfs cat' output looks good"
'
test_cmp mountdir/bigfile actual
'
test_expect_success FUSE
"cat ipfs/bigfile succeeds"
'
test_add_named_pipe
" Post http://127.0.0.1:
$PORT_API
/api/v0/add?encoding=json&progress=true&r=true&stream-channels=true:"
cat "ipfs/$HASH" >actual
'
test_expect_success FUSE
"cat ipfs/bigfile looks good"
'
test_cmp mountdir/bigfile actual
'
test_expect_success EXPENSIVE
"generate 100MB file using go-random"
'
test_kill_ipfs_daemon
random 104857600 42 >mountdir/bigfile
'
test_expect_success EXPENSIVE
"sha1 of the file looks ok"
'
echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
multihash -a=sha1 -e=hex mountdir/bigfile >sha1_actual &&
test_cmp sha1_expected sha1_actual
'
test_expect_success EXPENSIVE
"ipfs add bigfile succeeds"
'
ipfs add mountdir/bigfile >actual
'
test_expect_success EXPENSIVE
"ipfs add bigfile output looks good"
'
HASH="QmU9SWAPPmNEKZB8umYMmjYvN7VyHqABNvdA6GUi4MMEz3" &&
echo "added $HASH bigfile" >expected &&
test_cmp expected actual
'
test_expect_success EXPENSIVE
"ipfs cat succeeds"
'
ipfs cat "$HASH" | multihash -a=sha1 -e=hex >sha1_actual
'
test_expect_success EXPENSIVE
"ipfs cat output looks good"
'
ipfs cat "$HASH" >actual &&
test_cmp mountdir/bigfile actual
'
test_expect_success EXPENSIVE
"ipfs cat output hashed looks good"
'
echo "1114885b197b01e0f7ff584458dc236cb9477d2e736d" >sha1_expected &&
test_cmp sha1_expected sha1_actual
'
test_expect_success FUSE,EXPENSIVE
"cat ipfs/bigfile succeeds"
'
# should work offline
cat "ipfs/$HASH" | multihash -a=sha1 -e=hex >sha1_actual
'
test_expect_success FUSE,EXPENSIVE
"cat ipfs/bigfile looks good"
'
test_add_cat_file
test_cmp sha1_expected sha1_actual
'
test_expect_success
"useful error message when adding a named pipe"
'
test_expect_success
"ipfs add --only-hash succeeds"
'
mkfifo named-pipe &&
echo "unknown content for only-hash" | ipfs add --only-hash -q > oh_hash
test_expect_code 1 ipfs add named-pipe 2>actual &&
client_err "Error: Unrecognized file type for named-pipe: $(generic_stat named-pipe)" >expected &&
test_cmp expected actual
'
'
test_expect_success
"useful error message when recursively adding a named pipe"
'
#TODO: this doesn't work when online hence separated out from test_add_cat_file
mkdir named-pipe-dir &&
test_expect_success
"ipfs cat file fails"
'
mkfifo named-pipe-dir/named-pipe &&
test_must_fail ipfs cat $(cat oh_hash)
test_expect_code 1 ipfs add -r named-pipe-dir 2>actual &&
printf "Error: Post http://127.0.0.1:$PORT_API/api/v0/add?encoding=json&progress=true&r=true&stream-channels=true: Unrecognized file type for named-pipe-dir/named-pipe: $(generic_stat named-pipe-dir/named-pipe)\n" >expected &&
test_cmp expected actual
'
'
test_
kill_ipfs_daemon
test_
add_named_pipe
""
test_done
test_done
test/sharness/t0041-add-cat-offline.sh
deleted
100755 → 0
浏览文件 @
5b2d2ebd
#!/bin/sh
#
# Copyright (c) 2014 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#
test_description
=
"Test add and cat commands"
.
lib/test-lib.sh
client_err
()
{
printf
"
$@
\n\n
Use 'ipfs add --help' for information about this command
\n
"
}
test_init_ipfs
test_expect_success
"ipfs add file succeeds"
'
echo "some content" > afile &&
HASH=$(ipfs add -q afile)
'
test_expect_success
"ipfs add output looks good"
'
echo Qmb1EXrDyKhNWfvLPYK4do3M9nU7BuLAcbqBir6aUrDsRY > expected &&
echo $HASH > actual &&
test_cmp expected actual
'
test_expect_success
"ipfs add --only-hash succeeds"
'
ipfs add -q --only-hash afile > ho_output
'
test_expect_success
"ipfs add --only-hash output looks good"
'
test_cmp expected ho_output
'
test_expect_success
"ipfs cat file suceeds"
'
ipfs cat $HASH > out_1
'
test_expect_success
"output looks good"
'
test_cmp afile out_1
'
test_expect_success
"ipfs cat /ipfs/file succeeds"
'
ipfs cat /ipfs/$HASH > out_2
'
test_expect_success
"output looks good"
'
test_cmp afile out_2
'
test_expect_success
"ipfs add --only-hash succeeds"
'
echo "unknown content for only-hash" | ipfs add --only-hash -q > oh_hash
'
test_expect_success
"ipfs cat file fails"
'
test_must_fail ipfs cat $(cat oh_hash)
'
test_expect_success
"useful error message when adding a named pipe"
'
mkfifo named-pipe &&
test_expect_code 1 ipfs add named-pipe 2>actual &&
client_err "Error: Unrecognized file type for named-pipe: $(generic_stat named-pipe)" >expected &&
test_cmp expected actual
'
test_expect_success
"useful error message when recursively adding a named pipe"
'
mkdir named-pipe-dir &&
mkfifo named-pipe-dir/named-pipe &&
test_expect_code 1 ipfs add -r named-pipe-dir 2>actual &&
printf "Error: Unrecognized file type for named-pipe-dir/named-pipe: $(generic_stat named-pipe-dir/named-pipe)\n" >expected &&
test_cmp expected actual
'
test_done
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论