@cryptotaxi247 / kubo / commits / 2b2e570c2

sharness: test pin ls stream

Steven Allen committed Jul 12, 2019 at 08:06 UTC 2b2e570c2053dcb9449cc1df4a7252839ee756f8
1 file changed +28 -23
test/sharness/t0085-pins.sh
+28 -23
@@ -10,8 +10,9 @@ test_description="Test ipfs pinning operations"
10
11
12 test_pins() {
13 - EXTRA_ARGS=$1
14 - BASE=$2
13 + PIN_ARGS="$1"
14 + LS_ARGS="$2"
15 + BASE=$3
16 if [ -n "$BASE" ]; then
17 BASE_ARGS="--cid-base=$BASE"
18 fi
@@ -44,11 +45,11 @@ test_pins() {
45 '
46 fi
47
47 - test_expect_success "'ipfs pin add $EXTRA_ARGS' via stdin" '
48 - cat hashes | ipfs pin add $EXTRA_ARGS $BASE_ARGS | tee actual
48 + test_expect_success "'ipfs pin add $PIN_ARGS' via stdin" '
49 + cat hashes | ipfs pin add $PIN_ARGS $BASE_ARGS | tee actual
50 '
51
51 - test_expect_success "'ipfs pin add $EXTRA_ARGS' output looks good" '
52 + test_expect_success "'ipfs pin add $PIN_ARGS' output looks good" '
53 sed -e "s/^/pinned /; s/$/ recursively/" hashes > expected &&
54 test_cmp expected actual
55 '
@@ -69,8 +70,8 @@ test_pins() {
70 test_should_contain "$HASH_G ok" verify_out
71 '
72
72 - test_expect_success "ipfs pin ls $BASE_ARGS works" '
73 - ipfs pin ls $BASE_ARGS > ls_out &&
73 + test_expect_success "ipfs pin ls $LS_ARGS $BASE_ARGS works" '
74 + ipfs pin ls $LS_ARGS $BASE_ARGS > ls_out &&
75 test_should_contain "$HASH_A" ls_out &&
76 test_should_contain "$HASH_B" ls_out &&
77 test_should_contain "$HASH_C" ls_out &&
@@ -80,9 +81,9 @@ test_pins() {
81 test_should_contain "$HASH_G" ls_out
82 '
83
83 - test_expect_success "test pin ls $BASE_ARGS hash" '
84 + test_expect_success "test pin ls $LS_ARGS $BASE_ARGS hash" '
85 echo $HASH_B | test_must_fail grep /ipfs && # just to be sure
85 - ipfs pin ls $BASE_ARGS $HASH_B > ls_hash_out &&
86 + ipfs pin ls $LS_ARGS $BASE_ARGS $HASH_B > ls_hash_out &&
87 echo "$HASH_B recursive" > ls_hash_exp &&
88 test_cmp ls_hash_exp ls_hash_out
89 '
@@ -93,11 +94,11 @@ test_pins() {
94
95 test_expect_success "test pin update" '
96 ipfs pin add "$HASH_A" &&
96 - ipfs pin ls $BASE_ARGS | tee before_update &&
97 + ipfs pin ls $LS_ARGS $BASE_ARGS | tee before_update &&
98 test_should_contain "$HASH_A" before_update &&
99 test_must_fail grep -q "$HASH_B" before_update &&
100 ipfs pin update --unpin=true "$HASH_A" "$HASH_B" &&
100 - ipfs pin ls $BASE_ARGS > after_update &&
101 + ipfs pin ls $LS_ARGS $BASE_ARGS > after_update &&
102 test_must_fail grep -q "$HASH_A" after_update &&
103 test_should_contain "$HASH_B" after_update &&
104 ipfs pin rm "$HASH_B"
@@ -107,20 +108,20 @@ test_pins() {
108 RANDOM_HASH=Qme8uX5n9hn15pw9p6WcVKoziyyC9LXv4LEgvsmKMULjnV
109
110 test_pins_error_reporting() {
110 - EXTRA_ARGS=$1
111 + PIN_ARGS=$1
112
112 - test_expect_success "'ipfs pin add $EXTRA_ARGS' on non-existent hash should fail" '
113 - test_must_fail ipfs pin add $EXTRA_ARGS $RANDOM_HASH 2> err &&
113 + test_expect_success "'ipfs pin add $PIN_ARGS' on non-existent hash should fail" '
114 + test_must_fail ipfs pin add $PIN_ARGS $RANDOM_HASH 2> err &&
115 grep -q "not found" err
116 '
117 }
118
119 test_pin_dag_init() {
119 - EXTRA_ARGS=$1
120 + PIN_ARGS=$1
121
121 - test_expect_success "'ipfs add $EXTRA_ARGS --pin=false' 1MB file" '
122 + test_expect_success "'ipfs add $PIN_ARGS --pin=false' 1MB file" '
123 random 1048576 56 > afile &&
123 - HASH=`ipfs add $EXTRA_ARGS --pin=false -q afile`
124 + HASH=`ipfs add $PIN_ARGS --pin=false -q afile`
125 '
126 }
127
@@ -162,9 +163,11 @@ test_pin_progress() {
163
164 test_init_ipfs
165
165 -test_pins
166 -test_pins --progress
167 -test_pins '' base32
166 +test_pins '' '' ''
167 +test_pins --progress '' ''
168 +test_pins --progress --stream ''
169 +test_pins '' '' base32
170 +test_pins '' --stream base32
171
172 test_pins_error_reporting
173 test_pins_error_reporting --progress
@@ -176,9 +179,11 @@ test_pin_progress
179
180 test_launch_ipfs_daemon --offline
181
179 -test_pins
180 -test_pins --progress
181 -test_pins '' base32
182 +test_pins '' '' ''
183 +test_pins --progress '' ''
184 +test_pins --progress --stream ''
185 +test_pins '' '' base32
186 +test_pins '' --stream base32
187
188 test_pins_error_reporting
189 test_pins_error_reporting --progress