@cryptotaxi247 / kubo / commits / 5f59556ff

add -w comprehensive tests

made many more tests for ipfs add -w License: MIT Signed-off-by: Juan Batiz-Benet <juan@benet.ai>

Juan Batiz-Benet committed Jul 29, 2015 at 04:06 UTC 5f59556ff9275db62c1aaf0e18cf0913960fafec
2 files changed +148 -22
test/sharness/t0040-add-and-cat.sh
-22
@@ -212,28 +212,6 @@ test_expect_success "'ipfs cat' output looks good" '
212 test_cmp mountdir/bigfile actual
213 '
214
215 -test_expect_success "ipfs add -w succeeds" '
216 - ipfs add -w mountdir/hello.txt >actual
217 -'
218 -
219 -test_expect_success "ipfs add -w output looks good" '
220 - HASH_W1="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
221 - HASH_W2="QmVJfrqd4ogGZME6LWkkikAGddYgh9dBs2U14DHZZUBk7W" &&
222 - echo "added $HASH_W1 mountdir/hello.txt" >expected &&
223 - echo "added $HASH_W2 " >>expected &&
224 - test_cmp expected actual
225 -'
226 -
227 -test_expect_success "ipfs add -w succeeds (dir)" '
228 - ipfs add -r -w mountdir | tail -n1 >actual
229 -'
230 -
231 -test_expect_success "ipfs add -w output looks good (dir)" '
232 - HASH_W="Qmc341yGztU1o8n3c1u5xTYF3uE3zPPP2NYemG9MKz775V" &&
233 - echo "added $HASH_W " >expected &&
234 - test_cmp expected actual
235 -'
236 -
215 test_expect_success FUSE "cat ipfs/bigfile succeeds" '
216 cat "ipfs/$HASH" >actual
217 '
test/sharness/t0043-add-w.sh new
+148
@@ -0,0 +1,148 @@
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 add -w"
8 +
9 +add_w_m='QmazHkwx6mPmmCEi1jR5YzjjQd1g5XzKfYQLzRAg7x5uUk'
10 +
11 +add_w_1='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu m/4r93
12 +added Qmf82PSsMpUHcrqxa69KG6Qp5yeK7K9BTizXgG3nvzWcNG '
13 +
14 +add_w_12='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu m/4r93
15 +added QmVb4ntSZZnT2J2zvCmXKMJc52cmZYH6AB37MzeYewnkjs m/4u6ead
16 +added QmZPASVB6EsADrLN8S2sak34zEHL8mx4TAVsPJU9cNnQQJ '
17 +
18 +add_w_21='added QmVb4ntSZZnT2J2zvCmXKMJc52cmZYH6AB37MzeYewnkjs m/4u6ead
19 +added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu m/4r93
20 +added QmZPASVB6EsADrLN8S2sak34zEHL8mx4TAVsPJU9cNnQQJ '
21 +
22 +add_w_d1='added QmPcaX84tDiTfzdTn8GQxexodgeWH6mHjSss5Zfr5ojssb m/t_1wp-8a2/_jo7/-s782qgs
23 +added QmaVBqquUuXKjkyWHXaXfsaQUxAnsCKS95VRDHU8PzGA4K m/t_1wp-8a2/_jo7/15totauzkak-
24 +added QmaAHFG8cmhW3WLjofx5siSp44VV25ETN6ThzrU8iAqpkR m/t_1wp-8a2/_jo7/galecuirrj4r
25 +added QmeuSfhJNKwBESp1W9H8cfoMdBfW3AeHQDWXbNXQJYWp53 m/t_1wp-8a2/_jo7/mzo50r-1xidf5zx
26 +added QmYC3u5jGWuyFwvTxtvLYm2K3SpWZ31tg3NjpVVvh9cJaJ m/t_1wp-8a2/_jo7/wzvsihy
27 +added QmQkib3f9XNX5sj6WEahLUPFpheTcwSRJwUCSvjcv8b9by m/t_1wp-8a2/_jo7
28 +added QmNQoesMj1qp8ApE51NbtTjFYksyzkezPD4cat7V2kzbKN '
29 +
30 +add_w_d2='added QmVaKAt2eVftNKFfKhiBV7Mu5HjCugffuLqWqobSSFgiA7 m/t_1wp-8a2/h3qpecj0
31 +added QmU9Jqks8TPu4vFr6t7EKkAKQrSJuEujNj1AkzoCeTEDFJ m/ha6f0x7su6/gnz66h/1k0xpx34
32 +added QmSLYZycXAufRw3ePMVH2brbtYWCcWsmksGLbHcT8ia9Ke m/ha6f0x7su6/gnz66h/9cwudvacx
33 +added QmfYmpCCAMU9nLe7xbrYsHf5z2R2GxeQnsm4zavUhX9vq2 m/ha6f0x7su6/gnz66h/9ximv51cbo8
34 +added QmWgEE4e2kfx3b8HZcBk5cLrfhoi8kTMQP2MipgPhykuV3 m/ha6f0x7su6/gnz66h/b54ygh6gs
35 +added QmcLbqEqhREGednc6mrVtanee4WHKp5JnUfiwTTHCJwuDf m/ha6f0x7su6/gnz66h/lbl5
36 +added QmVPwNy8pZegpsNmsjjZvdTQn4uCeuZgtzhgWhRSQWjK9x m/ha6f0x7su6/gnz66h
37 +added QmPcaX84tDiTfzdTn8GQxexodgeWH6mHjSss5Zfr5ojssb m/t_1wp-8a2/_jo7/-s782qgs
38 +added QmaVBqquUuXKjkyWHXaXfsaQUxAnsCKS95VRDHU8PzGA4K m/t_1wp-8a2/_jo7/15totauzkak-
39 +added QmaAHFG8cmhW3WLjofx5siSp44VV25ETN6ThzrU8iAqpkR m/t_1wp-8a2/_jo7/galecuirrj4r
40 +added QmeuSfhJNKwBESp1W9H8cfoMdBfW3AeHQDWXbNXQJYWp53 m/t_1wp-8a2/_jo7/mzo50r-1xidf5zx
41 +added QmYC3u5jGWuyFwvTxtvLYm2K3SpWZ31tg3NjpVVvh9cJaJ m/t_1wp-8a2/_jo7/wzvsihy
42 +added QmQkib3f9XNX5sj6WEahLUPFpheTcwSRJwUCSvjcv8b9by m/t_1wp-8a2/_jo7
43 +added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu m/4r93
44 +added QmTmc46fhKC8Liuh5soy1VotdnHcqLu3r6HpPGwDZCnqL1 '
45 +
46 +add_w_r='QmWpSjVaMts6cXr4g4uQ9AVadunLKxW7Fhyxk3TXo36hEf'
47 +
48 +. lib/test-lib.sh
49 +
50 +test_add_w() {
51 +
52 + test_expect_success "go-random-files is installed" '
53 + type random-files
54 + '
55 +
56 + test_expect_success "random-files generates test files" '
57 + random-files --seed 7547632 --files 5 --dirs 2 --depth 3 m &&
58 + echo "$add_w_m" >expected &&
59 + ipfs add -q -r m | tail -n1 >actual &&
60 + test_cmp expected actual
61 + '
62 +
63 + # test single file
64 + test_expect_success "ipfs add -w (single file) succeeds" '
65 + ipfs add -w m/4r93 >actual
66 + '
67 +
68 + test_expect_success "ipfs add -w (single file) is correct" '
69 + echo "$add_w_1" >expected &&
70 + test_cmp expected actual
71 + '
72 +
73 + # test two files together
74 + test_expect_success "ipfs add -w (multiple) succeeds" '
75 + ipfs add -w m/4r93 m/4u6ead >actual
76 + '
77 +
78 + test_expect_success "ipfs add -w (multiple) is correct" '
79 + echo "$add_w_12" >expected &&
80 + test_cmp expected actual
81 + '
82 +
83 + test_expect_success "ipfs add -w (multiple) succeeds" '
84 + ipfs add -w m/4u6ead m/4r93 >actual
85 + '
86 +
87 + test_expect_success "ipfs add -w (multiple) orders" '
88 + echo "$add_w_21" >expected &&
89 + test_cmp expected actual
90 + '
91 +
92 + # test a directory
93 + test_expect_success "ipfs add -w -r (dir) succeeds" '
94 + ipfs add -r -w m/t_1wp-8a2/_jo7 >actual
95 + '
96 +
97 + test_expect_success "ipfs add -w -r (dir) is correct" '
98 + echo "$add_w_d1" >expected &&
99 + test_cmp expected actual
100 + '
101 +
102 + # test files and directory
103 + test_expect_success "ipfs add -w -r <many> succeeds" '
104 + ipfs add -w -r m/t_1wp-8a2/h3qpecj0 \
105 + m/ha6f0x7su6/gnz66h m/t_1wp-8a2/_jo7 m/4r93 >actual
106 + '
107 +
108 + test_expect_success "ipfs add -w -r <many> is correct" '
109 + echo "$add_w_d2" >expected &&
110 + test_cmp expected actual
111 + '
112 +
113 + # test -w -r m/* == -r m
114 + test_expect_success "ipfs add -w -r m/* == add -r m succeeds" '
115 + ipfs add -q -w -r m/* | tail -n1 >actual
116 + '
117 +
118 + test_expect_success "ipfs add -w -r m/* == add -r m is correct" '
119 + echo "$add_w_m" >expected &&
120 + test_cmp expected actual
121 + '
122 +
123 + # test repeats together
124 + test_expect_success "ipfs add -w (repeats) succeeds" '
125 + ipfs add -q -w -r m/t_1wp-8a2/h3qpecj0 m/ha6f0x7su6/gnz66h \
126 + m/t_1wp-8a2/_jo7 m/4r93 m/t_1wp-8a2 m/t_1wp-8a2 m/4r93 \
127 + m/4r93 m/ha6f0x7su6/_rwujlf3qh_g08 \
128 + m/ha6f0x7su6/gnz66h/9cwudvacx | tail -n1 >actual
129 + '
130 +
131 + test_expect_success "ipfs add -w (repeats) is correct" '
132 + echo "$add_w_r" >expected &&
133 + test_cmp expected actual
134 + '
135 +
136 +}
137 +
138 +test_init_ipfs
139 +
140 +test_add_w
141 +
142 +test_launch_ipfs_daemon
143 +
144 +test_add_w
145 +
146 +test_kill_ipfs_daemon
147 +
148 +test_done