@cryptotaxi247 / kubo / commits / 3f4d38fec

sharness: correctness. must have &&

cc @whyrusleeping

Juan Batiz-Benet committed Jan 30, 2015 at 01:04 UTC 3f4d38fecad533a956211cac7a1eff1919521196
1 file changed +53 -53
test/sharness/t0080-repo.sh
+53 -53
@@ -12,8 +12,8 @@ test_init_ipfs
12 test_launch_ipfs_daemon
13
14 test_expect_success "'ipfs add afile' succeeds" '
15 - echo "some text" >afile
16 - HASH=`ipfs add -q afile`
15 + echo "some text" >afile &&
16 + HASH=`ipfs add -q afile` &&
17 printf "$HASH" >hashfile
18 '
19
@@ -26,27 +26,27 @@ test_expect_success "'ipfs repo gc' succeeds" '
26 '
27
28 test_expect_success "'ipfs repo gc' looks good (empty)" '
29 - printf "" >empty
29 + printf "" >empty &&
30 test_cmp empty gc_out_actual
31 '
32
33 test_expect_success "'ipfs repo gc' doesnt remove file" '
34 - ipfs cat "$HASH" >out
34 + ipfs cat "$HASH" >out &&
35 test_cmp out afile
36 '
37
38 test_expect_success "'ipfs pin rm' succeeds" '
39 - echo "unpinned $HASH" >expected1
40 - ipfs pin rm -r "$HASH" >actual1
39 + echo "unpinned $HASH" >expected1 &&
40 + ipfs pin rm -r "$HASH" >actual1 &&
41 test_cmp expected1 actual1
42 '
43
44 test_expect_success "file no longer pinned" '
45 # we expect the welcome files to show up here
46 - echo QmPXME1oRtoT627YKaDPDQ3PwA8tdP9rWuAAweLzqSwAWT >expected2
47 - ipfs refs -r QmPXME1oRtoT627YKaDPDQ3PwA8tdP9rWuAAweLzqSwAWT >>expected2
48 - cat expected2 | sort >expected_sorted2
49 - ipfs pin ls -type=recursive | sort >actual2
46 + echo QmPXME1oRtoT627YKaDPDQ3PwA8tdP9rWuAAweLzqSwAWT >expected2 &&
47 + ipfs refs -r QmPXME1oRtoT627YKaDPDQ3PwA8tdP9rWuAAweLzqSwAWT >>expected2 &&
48 + cat expected2 | sort >expected_sorted2 &&
49 + ipfs pin ls -type=recursive | sort >actual2 &&
50 test_cmp expected_sorted2 actual2
51 '
52
@@ -55,93 +55,93 @@ test_expect_success "recursively pin afile" '
55 '
56
57 test_expect_success "pinning directly should fail now" '
58 - echo "Error: pin: $HASH already pinned recursively" >expected3
59 - ipfs pin add "$HASH" 2>actual3
58 + echo "Error: pin: $HASH already pinned recursively" >expected3 &&
59 + !(ipfs pin add "$HASH" 2>actual3) &&
60 test_cmp expected3 actual3
61 '
62
63 test_expect_success "'ipfs pin rm <hash>' should fail" '
64 - echo "Error: $HASH is pinned recursively" >expected4
65 - ipfs pin rm "$HASH" 2>actual4
64 + echo "Error: $HASH is pinned recursively" >expected4 &&
65 + !(ipfs pin rm "$HASH" 2>actual4) &&
66 test_cmp expected4 actual4
67 '
68
69 test_expect_success "remove recursive pin, add direct" '
70 - echo "unpinned $HASH" >expected5
71 - ipfs pin rm -r "$HASH" >actual5
72 - test_cmp expected5 actual5
70 + echo "unpinned $HASH" >expected5 &&
71 + ipfs pin rm -r "$HASH" >actual5 &&
72 + test_cmp expected5 actual5 &&
73 ipfs pin add "$HASH"
74 '
75
76 test_expect_success "remove direct pin" '
77 - echo "unpinned $HASH" >expected6
78 - ipfs pin rm "$HASH" >actual6
77 + echo "unpinned $HASH" >expected6 &&
78 + ipfs pin rm "$HASH" >actual6 &&
79 test_cmp expected6 actual6
80 '
81
82 test_expect_success "'ipfs repo gc' removes file" '
83 - echo "removed $HASH" >expected7
84 - ipfs repo gc >actual7
83 + echo "removed $HASH" >expected7 &&
84 + ipfs repo gc >actual7 &&
85 test_cmp expected7 actual7
86 '
87
88 test_expect_success "'ipfs refs local' no longer shows file" '
89 - echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn >expected8
90 - echo QmPXME1oRtoT627YKaDPDQ3PwA8tdP9rWuAAweLzqSwAWT >>expected8
91 - ipfs refs -r QmPXME1oRtoT627YKaDPDQ3PwA8tdP9rWuAAweLzqSwAWT >>expected8
92 - cat expected8 | sort >expected_sorted8
93 - ipfs refs local | sort >actual8
89 + echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn >expected8 &&
90 + echo QmPXME1oRtoT627YKaDPDQ3PwA8tdP9rWuAAweLzqSwAWT >>expected8 &&
91 + ipfs refs -r QmPXME1oRtoT627YKaDPDQ3PwA8tdP9rWuAAweLzqSwAWT >>expected8 &&
92 + cat expected8 | sort >expected_sorted8 &&
93 + ipfs refs local | sort >actual8 &&
94 test_cmp expected_sorted8 actual8
95 '
96
97 test_expect_success "adding multiblock random file succeeds" '
98 - random 1000000 >multiblock
98 + random 1000000 >multiblock &&
99 MBLOCKHASH=`ipfs add -q multiblock`
100 '
101
102 test_expect_success "'ipfs pin ls -type=indirect' is correct" '
103 - ipfs refs "$MBLOCKHASH" >refsout
104 - ipfs refs -r "QmPXME1oRtoT627YKaDPDQ3PwA8tdP9rWuAAweLzqSwAWT" >>refsout
105 - cat refsout | sort >refsout_sorted
106 - ipfs pin ls -type=indirect | sort >indirectpins
103 + ipfs refs "$MBLOCKHASH" >refsout &&
104 + ipfs refs -r "QmPXME1oRtoT627YKaDPDQ3PwA8tdP9rWuAAweLzqSwAWT" >>refsout &&
105 + cat refsout | sort >refsout_sorted &&
106 + ipfs pin ls -type=indirect | sort >indirectpins &&
107 test_cmp refsout_sorted indirectpins
108 '
109
110 test_expect_success "pin something directly" '
111 - echo "ipfs is so awesome" >awesome
112 - DIRECTPIN=`ipfs add -q awesome`
113 - echo "unpinned $DIRECTPIN" >expected9
114 - ipfs pin rm -r "$DIRECTPIN" >actual9
115 - test_cmp expected9 actual9
116 -
117 - echo "pinned $DIRECTPIN directly" >expected10
118 - ipfs pin add "$DIRECTPIN" >actual10
111 + echo "ipfs is so awesome" >awesome &&
112 + DIRECTPIN=`ipfs add -q awesome` &&
113 + echo "unpinned $DIRECTPIN" >expected9 &&
114 + ipfs pin rm -r "$DIRECTPIN" >actual9 &&
115 + test_cmp expected9 actual9 &&
116 +
117 + echo "pinned $DIRECTPIN directly" >expected10 &&
118 + ipfs pin add "$DIRECTPIN" >actual10 &&
119 test_cmp expected10 actual10
120 '
121
122 test_expect_success "'ipfs pin ls -type=direct' is correct" '
123 - echo "$DIRECTPIN" >directpinexpected
124 - echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn >>directpinexpected
125 - cat directpinexpected | sort >dp_exp_sorted
126 - ipfs pin ls -type=direct | sort >directpinout
123 + echo "$DIRECTPIN" >directpinexpected &&
124 + echo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn >>directpinexpected &&
125 + cat directpinexpected | sort >dp_exp_sorted &&
126 + ipfs pin ls -type=direct | sort >directpinout &&
127 test_cmp dp_exp_sorted directpinout
128 '
129
130 test_expect_success "'ipfs pin ls -type=recursive' is correct" '
131 - echo "$MBLOCKHASH" >rp_expected
132 - echo QmPXME1oRtoT627YKaDPDQ3PwA8tdP9rWuAAweLzqSwAWT >>rp_expected
133 - ipfs refs -r "QmPXME1oRtoT627YKaDPDQ3PwA8tdP9rWuAAweLzqSwAWT" >>rp_expected
134 - cat rp_expected | sort >rp_exp_sorted
135 - ipfs pin ls -type=recursive | sort >rp_actual
131 + echo "$MBLOCKHASH" >rp_expected &&
132 + echo QmPXME1oRtoT627YKaDPDQ3PwA8tdP9rWuAAweLzqSwAWT >>rp_expected &&
133 + ipfs refs -r "QmPXME1oRtoT627YKaDPDQ3PwA8tdP9rWuAAweLzqSwAWT" >>rp_expected &&
134 + cat rp_expected | sort >rp_exp_sorted &&
135 + ipfs pin ls -type=recursive | sort >rp_actual &&
136 test_cmp rp_exp_sorted rp_actual
137 '
138
139 test_expect_success "'ipfs pin ls -type=all' is correct" '
140 - cat directpinout >allpins
141 - cat rp_actual >>allpins
142 - cat indirectpins >>allpins
143 - cat allpins | sort >allpins_sorted
144 - ipfs pin ls -type=all | sort >actual_allpins
140 + cat directpinout >allpins &&
141 + cat rp_actual >>allpins &&
142 + cat indirectpins >>allpins &&
143 + cat allpins | sort >allpins_sorted &&
144 + ipfs pin ls -type=all | sort >actual_allpins &&
145 test_cmp allpins_sorted actual_allpins
146 '
147