提交 02dfb9f8 作者: Christian Couder

t0045: test ipfs ls online as well as offline

To do that the current tests are move inside a
test_ls_cmd() function. This function is then first
called before running the daemon for offline tests
and then after starting the daemon for online tests.

License: MIT
Signed-off-by: 's avatarChristian Couder <chriscool@tuxfamily.org>
上级 11dc94b5
......@@ -10,8 +10,10 @@ test_description="Test ls command"
test_init_ipfs
test_expect_success "'ipfs add -r testData' succeeds" '
mkdir testData testData/d1 testData/d2 &&
test_ls_cmd() {
test_expect_success "'ipfs add -r testData' succeeds" '
mkdir -p testData testData/d1 testData/d2 &&
echo "test" >testData/f1 &&
echo "data" >testData/f2 &&
echo "hello" >testData/d1/a &&
......@@ -19,9 +21,9 @@ test_expect_success "'ipfs add -r testData' succeeds" '
echo "world" >testData/d2/a &&
random 1024 42 >testData/d2/1024 &&
ipfs add -r testData >actual_add
'
'
test_expect_success "'ipfs add' output looks good" '
test_expect_success "'ipfs add' output looks good" '
cat <<-\EOF >expected_add &&
added QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe testData/d1/128
added QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN testData/d1/a
......@@ -34,13 +36,13 @@ test_expect_success "'ipfs add' output looks good" '
added QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj testData
EOF
test_cmp expected_add actual_add
'
'
test_expect_success "'ipfs ls <three dir hashes>' succeeds" '
test_expect_success "'ipfs ls <three dir hashes>' succeeds" '
ipfs ls QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls
'
'
test_expect_success "'ipfs ls <three dir hashes>' output looks good" '
test_expect_success "'ipfs ls <three dir hashes>' output looks good" '
cat <<-\EOF >expected_ls &&
QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj:
QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss 246 d1/
......@@ -58,13 +60,13 @@ test_expect_success "'ipfs ls <three dir hashes>' output looks good" '
EOF
test_cmp expected_ls actual_ls
'
'
test_expect_success "'ipfs ls --headers <three dir hashes>' succeeds" '
test_expect_success "'ipfs ls --headers <three dir hashes>' succeeds" '
ipfs ls --headers QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls_headers
'
'
test_expect_success "'ipfs ls --headers <three dir hashes>' output looks good" '
test_expect_success "'ipfs ls --headers <three dir hashes>' output looks good" '
cat <<-\EOF >expected_ls_headers &&
QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj:
Hash Size Name
......@@ -85,6 +87,15 @@ test_expect_success "'ipfs ls --headers <three dir hashes>' output looks good"
EOF
test_cmp expected_ls_headers actual_ls_headers
'
'
}
# should work offline
test_ls_cmd
# should work online
test_launch_ipfs_daemon
test_ls_cmd
test_kill_ipfs_daemon
test_done
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论