Add test for adding directory with --raw-leaves option.
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
Kevin Atkinson committed
Jan 2, 2017 at 21:19 UTC
3526c26f3159d20a61e4fc19029f3a6806b4dcba
1 file changed
+66
-51
test/sharness/t0040-add-and-cat.sh
+66
-51
@@ -315,22 +315,73 @@ test_expect_success "ipfs cat with built input output looks good" '
315
test_cmp expected actual
316
'
317
318
-test_expect_success "'ipfs add -r' succeeds" '
319
- mkdir mountdir/planets &&
320
- echo "Hello Mars!" >mountdir/planets/mars.txt &&
321
- echo "Hello Venus!" >mountdir/planets/venus.txt &&
322
- ipfs add -r mountdir/planets >actual
323
-'
318
+add_directory() {
319
+ EXTRA_ARGS=$1
320
+
321
+ test_expect_success "'ipfs add -r $EXTRA_ARGS' succeeds" '
322
+ mkdir mountdir/planets &&
323
+ echo "Hello Mars!" >mountdir/planets/mars.txt &&
324
+ echo "Hello Venus!" >mountdir/planets/venus.txt &&
325
+ ipfs add -r $EXTRA_ARGS mountdir/planets >actual
326
+ '
327
+
328
+ test_expect_success "'ipfs add -r $EXTRA_ARGS' output looks good" '
329
+ echo "added $MARS planets/mars.txt" >expected &&
330
+ echo "added $VENUS planets/venus.txt" >>expected &&
331
+ echo "added $PLANETS planets" >>expected &&
332
+ test_cmp expected actual
333
+ '
334
+
335
+ test_expect_success "ipfs cat accept many hashes from built input" '
336
+ { echo "$MARS"; echo "$VENUS"; } | ipfs cat >actual
337
+ '
338
+
339
+ test_expect_success "ipfs cat output looks good" '
340
+ cat mountdir/planets/mars.txt mountdir/planets/venus.txt >expected &&
341
+ test_cmp expected actual
342
+ '
343
+
344
+ test_expect_success "ipfs cat accept many hashes as args" '
345
+ ipfs cat "$MARS" "$VENUS" >actual
346
+ '
347
+
348
+ test_expect_success "ipfs cat output looks good" '
349
+ test_cmp expected actual
350
+ '
351
+
352
+ test_expect_success "ipfs cat with both arg and stdin" '
353
+ echo "$MARS" | ipfs cat "$VENUS" >actual
354
+ '
355
+
356
+ test_expect_success "ipfs cat output looks good" '
357
+ cat mountdir/planets/venus.txt >expected &&
358
+ test_cmp expected actual
359
+ '
360
+
361
+ test_expect_success "ipfs cat with two args and stdin" '
362
+ echo "$MARS" | ipfs cat "$VENUS" "$VENUS" >actual
363
+ '
364
+
365
+ test_expect_success "ipfs cat output looks good" '
366
+ cat mountdir/planets/venus.txt mountdir/planets/venus.txt >expected &&
367
+ test_cmp expected actual
368
+ '
369
+
370
+ test_expect_success "cleanup" '
371
+ rm -r mountdir/planets
372
+ '
373
+}
374
+
375
+PLANETS="QmWSgS32xQEcXMeqd3YPJLrNBLSdsfYCep2U7CFkyrjXwY"
376
+MARS="QmPrrHqJzto9m7SyiRzarwkqPcCSsKR2EB1AyqJfe8L8tN"
377
+VENUS="QmU5kp3BH3B8tnWUU2Pikdb2maksBNkb92FHRr56hyghh4"
378
+add_directory
379
+
380
+PLANETS="QmfWfQfKCY5Ukv9peBbxM5vqWM9BzmqUSXvdCgjT2wsiBT"
381
+MARS="zb2rhZdTkQNawVajsTNiYc9cTPHqgLdJVvBRkZok9RjkgQYRU"
382
+VENUS="zb2rhn6TGvnUaMAg4VV4y9HVx5W42HihcH4jsyrDv8mkepFqq"
383
+add_directory '--raw-leaves'
384
325
-test_expect_success "'ipfs add -r' output looks good" '
326
- PLANETS="QmWSgS32xQEcXMeqd3YPJLrNBLSdsfYCep2U7CFkyrjXwY" &&
327
- MARS="QmPrrHqJzto9m7SyiRzarwkqPcCSsKR2EB1AyqJfe8L8tN" &&
328
- VENUS="QmU5kp3BH3B8tnWUU2Pikdb2maksBNkb92FHRr56hyghh4" &&
329
- echo "added $MARS planets/mars.txt" >expected &&
330
- echo "added $VENUS planets/venus.txt" >>expected &&
331
- echo "added $PLANETS planets" >>expected &&
332
- test_cmp expected actual
333
-'
385
386
test_expect_success "'ipfs add -rn' succeeds" '
387
mkdir -p mountdir/moons/jupiter &&
@@ -357,42 +408,6 @@ test_expect_success "'ipfs add -rn' output looks good" '
408
test_cmp expected actual
409
'
410
360
-test_expect_success "ipfs cat accept many hashes from built input" '
361
- { echo "$MARS"; echo "$VENUS"; } | ipfs cat >actual
362
-'
363
-
364
-test_expect_success "ipfs cat output looks good" '
365
- cat mountdir/planets/mars.txt mountdir/planets/venus.txt >expected &&
366
- test_cmp expected actual
367
-'
368
-
369
-test_expect_success "ipfs cat accept many hashes as args" '
370
- ipfs cat "$MARS" "$VENUS" >actual
371
-'
372
-
373
-test_expect_success "ipfs cat output looks good" '
374
- test_cmp expected actual
375
-'
376
-
377
-test_expect_success "ipfs cat with both arg and stdin" '
378
- echo "$MARS" | ipfs cat "$VENUS" >actual
379
-'
380
-
381
-test_expect_success "ipfs cat output looks good" '
382
- cat mountdir/planets/venus.txt >expected &&
383
- test_cmp expected actual
384
-'
385
-
386
-test_expect_success "ipfs cat with two args and stdin" '
387
- echo "$MARS" | ipfs cat "$VENUS" "$VENUS" >actual
388
-'
389
-
390
-test_expect_success "ipfs cat output looks good" '
391
- cat mountdir/planets/venus.txt mountdir/planets/venus.txt >expected &&
392
- test_cmp expected actual
393
-'
394
-
395
-
411
test_expect_success "go-random is installed" '
412
type random
413
'