github.com/keltia/go-ipfs@v0.3.8-0.20150909044612-210793031c63/test/sharness/t0045-ls.sh (about) 1 #!/bin/sh 2 # 3 # Copyright (c) 2014 Christian Couder 4 # MIT Licensed; see the LICENSE file in this repository. 5 # 6 7 test_description="Test ls command" 8 9 . lib/test-lib.sh 10 11 test_init_ipfs 12 13 test_ls_cmd() { 14 15 test_expect_success "'ipfs add -r testData' succeeds" ' 16 mkdir -p testData testData/d1 testData/d2 && 17 echo "test" >testData/f1 && 18 echo "data" >testData/f2 && 19 echo "hello" >testData/d1/a && 20 random 128 42 >testData/d1/128 && 21 echo "world" >testData/d2/a && 22 random 1024 42 >testData/d2/1024 && 23 ipfs add -r testData >actual_add 24 ' 25 26 test_expect_success "'ipfs add' output looks good" ' 27 cat <<-\EOF >expected_add && 28 added QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe testData/d1/128 29 added QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN testData/d1/a 30 added QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss testData/d1 31 added QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd testData/d2/1024 32 added QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL testData/d2/a 33 added QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy testData/d2 34 added QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH testData/f1 35 added QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M testData/f2 36 added QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj testData 37 EOF 38 test_cmp expected_add actual_add 39 ' 40 41 test_expect_success "'ipfs ls <three dir hashes>' succeeds" ' 42 ipfs ls QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls 43 ' 44 45 test_expect_success "'ipfs ls <three dir hashes>' output looks good" ' 46 cat <<-\EOF >expected_ls && 47 QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj: 48 QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss 246 d1/ 49 QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy 1143 d2/ 50 QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH 13 f1 51 QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M 13 f2 52 53 QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy: 54 QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd 1035 1024 55 QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL 14 a 56 57 QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss: 58 QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe 139 128 59 QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN 14 a 60 61 EOF 62 test_cmp expected_ls actual_ls 63 ' 64 65 test_expect_success "'ipfs ls --headers <three dir hashes>' succeeds" ' 66 ipfs ls --headers QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss >actual_ls_headers 67 ' 68 69 test_expect_success "'ipfs ls --headers <three dir hashes>' output looks good" ' 70 cat <<-\EOF >expected_ls_headers && 71 QmfNy183bXiRVyrhyWtq3TwHn79yHEkiAGFr18P7YNzESj: 72 Hash Size Name 73 QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss 246 d1/ 74 QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy 1143 d2/ 75 QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH 13 f1 76 QmNtocSs7MoDkJMc1RkyisCSKvLadujPsfJfSdJ3e1eA1M 13 f2 77 78 QmR3jhV4XpxxPjPT3Y8vNnWvWNvakdcT3H6vqpRBsX1MLy: 79 Hash Size Name 80 QmbQBUSRL9raZtNXfpTDeaxQapibJEG6qEY8WqAN22aUzd 1035 1024 81 QmaRGe7bVmVaLmxbrMiVNXqW4pRNNp3xq7hFtyRKA3mtJL 14 a 82 83 QmSix55yz8CzWXf5ZVM9vgEvijnEeeXiTSarVtsqiiCJss: 84 Hash Size Name 85 QmQNd6ubRXaNG6Prov8o6vk3bn6eWsj9FxLGrAVDUAGkGe 139 128 86 QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN 14 a 87 88 EOF 89 test_cmp expected_ls_headers actual_ls_headers 90 ' 91 } 92 93 # should work offline 94 test_ls_cmd 95 96 # should work online 97 test_launch_ipfs_daemon 98 test_ls_cmd 99 test_kill_ipfs_daemon 100 101 test_done