mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-29 17:36:38 +08:00
add -w comprehensive tests
made many more tests for ipfs add -w License: MIT Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
This commit is contained in:
@ -212,28 +212,6 @@ test_expect_success "'ipfs cat' output looks good" '
|
||||
test_cmp mountdir/bigfile actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -w succeeds" '
|
||||
ipfs add -w mountdir/hello.txt >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -w output looks good" '
|
||||
HASH_W1="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
|
||||
HASH_W2="QmVJfrqd4ogGZME6LWkkikAGddYgh9dBs2U14DHZZUBk7W" &&
|
||||
echo "added $HASH_W1 mountdir/hello.txt" >expected &&
|
||||
echo "added $HASH_W2 " >>expected &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -w succeeds (dir)" '
|
||||
ipfs add -r -w mountdir | tail -n1 >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -w output looks good (dir)" '
|
||||
HASH_W="Qmc341yGztU1o8n3c1u5xTYF3uE3zPPP2NYemG9MKz775V" &&
|
||||
echo "added $HASH_W " >expected &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success FUSE "cat ipfs/bigfile succeeds" '
|
||||
cat "ipfs/$HASH" >actual
|
||||
'
|
||||
|
148
test/sharness/t0043-add-w.sh
Executable file
148
test/sharness/t0043-add-w.sh
Executable file
@ -0,0 +1,148 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2014 Christian Couder
|
||||
# MIT Licensed; see the LICENSE file in this repository.
|
||||
#
|
||||
|
||||
test_description="Test add -w"
|
||||
|
||||
add_w_m='QmazHkwx6mPmmCEi1jR5YzjjQd1g5XzKfYQLzRAg7x5uUk'
|
||||
|
||||
add_w_1='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu m/4r93
|
||||
added Qmf82PSsMpUHcrqxa69KG6Qp5yeK7K9BTizXgG3nvzWcNG '
|
||||
|
||||
add_w_12='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu m/4r93
|
||||
added QmVb4ntSZZnT2J2zvCmXKMJc52cmZYH6AB37MzeYewnkjs m/4u6ead
|
||||
added QmZPASVB6EsADrLN8S2sak34zEHL8mx4TAVsPJU9cNnQQJ '
|
||||
|
||||
add_w_21='added QmVb4ntSZZnT2J2zvCmXKMJc52cmZYH6AB37MzeYewnkjs m/4u6ead
|
||||
added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu m/4r93
|
||||
added QmZPASVB6EsADrLN8S2sak34zEHL8mx4TAVsPJU9cNnQQJ '
|
||||
|
||||
add_w_d1='added QmPcaX84tDiTfzdTn8GQxexodgeWH6mHjSss5Zfr5ojssb m/t_1wp-8a2/_jo7/-s782qgs
|
||||
added QmaVBqquUuXKjkyWHXaXfsaQUxAnsCKS95VRDHU8PzGA4K m/t_1wp-8a2/_jo7/15totauzkak-
|
||||
added QmaAHFG8cmhW3WLjofx5siSp44VV25ETN6ThzrU8iAqpkR m/t_1wp-8a2/_jo7/galecuirrj4r
|
||||
added QmeuSfhJNKwBESp1W9H8cfoMdBfW3AeHQDWXbNXQJYWp53 m/t_1wp-8a2/_jo7/mzo50r-1xidf5zx
|
||||
added QmYC3u5jGWuyFwvTxtvLYm2K3SpWZ31tg3NjpVVvh9cJaJ m/t_1wp-8a2/_jo7/wzvsihy
|
||||
added QmQkib3f9XNX5sj6WEahLUPFpheTcwSRJwUCSvjcv8b9by m/t_1wp-8a2/_jo7
|
||||
added QmNQoesMj1qp8ApE51NbtTjFYksyzkezPD4cat7V2kzbKN '
|
||||
|
||||
add_w_d2='added QmVaKAt2eVftNKFfKhiBV7Mu5HjCugffuLqWqobSSFgiA7 m/t_1wp-8a2/h3qpecj0
|
||||
added QmU9Jqks8TPu4vFr6t7EKkAKQrSJuEujNj1AkzoCeTEDFJ m/ha6f0x7su6/gnz66h/1k0xpx34
|
||||
added QmSLYZycXAufRw3ePMVH2brbtYWCcWsmksGLbHcT8ia9Ke m/ha6f0x7su6/gnz66h/9cwudvacx
|
||||
added QmfYmpCCAMU9nLe7xbrYsHf5z2R2GxeQnsm4zavUhX9vq2 m/ha6f0x7su6/gnz66h/9ximv51cbo8
|
||||
added QmWgEE4e2kfx3b8HZcBk5cLrfhoi8kTMQP2MipgPhykuV3 m/ha6f0x7su6/gnz66h/b54ygh6gs
|
||||
added QmcLbqEqhREGednc6mrVtanee4WHKp5JnUfiwTTHCJwuDf m/ha6f0x7su6/gnz66h/lbl5
|
||||
added QmVPwNy8pZegpsNmsjjZvdTQn4uCeuZgtzhgWhRSQWjK9x m/ha6f0x7su6/gnz66h
|
||||
added QmPcaX84tDiTfzdTn8GQxexodgeWH6mHjSss5Zfr5ojssb m/t_1wp-8a2/_jo7/-s782qgs
|
||||
added QmaVBqquUuXKjkyWHXaXfsaQUxAnsCKS95VRDHU8PzGA4K m/t_1wp-8a2/_jo7/15totauzkak-
|
||||
added QmaAHFG8cmhW3WLjofx5siSp44VV25ETN6ThzrU8iAqpkR m/t_1wp-8a2/_jo7/galecuirrj4r
|
||||
added QmeuSfhJNKwBESp1W9H8cfoMdBfW3AeHQDWXbNXQJYWp53 m/t_1wp-8a2/_jo7/mzo50r-1xidf5zx
|
||||
added QmYC3u5jGWuyFwvTxtvLYm2K3SpWZ31tg3NjpVVvh9cJaJ m/t_1wp-8a2/_jo7/wzvsihy
|
||||
added QmQkib3f9XNX5sj6WEahLUPFpheTcwSRJwUCSvjcv8b9by m/t_1wp-8a2/_jo7
|
||||
added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu m/4r93
|
||||
added QmTmc46fhKC8Liuh5soy1VotdnHcqLu3r6HpPGwDZCnqL1 '
|
||||
|
||||
add_w_r='QmWpSjVaMts6cXr4g4uQ9AVadunLKxW7Fhyxk3TXo36hEf'
|
||||
|
||||
. lib/test-lib.sh
|
||||
|
||||
test_add_w() {
|
||||
|
||||
test_expect_success "go-random-files is installed" '
|
||||
type random-files
|
||||
'
|
||||
|
||||
test_expect_success "random-files generates test files" '
|
||||
random-files --seed 7547632 --files 5 --dirs 2 --depth 3 m &&
|
||||
echo "$add_w_m" >expected &&
|
||||
ipfs add -q -r m | tail -n1 >actual &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
# test single file
|
||||
test_expect_success "ipfs add -w (single file) succeeds" '
|
||||
ipfs add -w m/4r93 >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -w (single file) is correct" '
|
||||
echo "$add_w_1" >expected &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
# test two files together
|
||||
test_expect_success "ipfs add -w (multiple) succeeds" '
|
||||
ipfs add -w m/4r93 m/4u6ead >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -w (multiple) is correct" '
|
||||
echo "$add_w_12" >expected &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -w (multiple) succeeds" '
|
||||
ipfs add -w m/4u6ead m/4r93 >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -w (multiple) orders" '
|
||||
echo "$add_w_21" >expected &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
# test a directory
|
||||
test_expect_success "ipfs add -w -r (dir) succeeds" '
|
||||
ipfs add -r -w m/t_1wp-8a2/_jo7 >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -w -r (dir) is correct" '
|
||||
echo "$add_w_d1" >expected &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
# test files and directory
|
||||
test_expect_success "ipfs add -w -r <many> succeeds" '
|
||||
ipfs add -w -r m/t_1wp-8a2/h3qpecj0 \
|
||||
m/ha6f0x7su6/gnz66h m/t_1wp-8a2/_jo7 m/4r93 >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -w -r <many> is correct" '
|
||||
echo "$add_w_d2" >expected &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
# test -w -r m/* == -r m
|
||||
test_expect_success "ipfs add -w -r m/* == add -r m succeeds" '
|
||||
ipfs add -q -w -r m/* | tail -n1 >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -w -r m/* == add -r m is correct" '
|
||||
echo "$add_w_m" >expected &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
# test repeats together
|
||||
test_expect_success "ipfs add -w (repeats) succeeds" '
|
||||
ipfs add -q -w -r m/t_1wp-8a2/h3qpecj0 m/ha6f0x7su6/gnz66h \
|
||||
m/t_1wp-8a2/_jo7 m/4r93 m/t_1wp-8a2 m/t_1wp-8a2 m/4r93 \
|
||||
m/4r93 m/ha6f0x7su6/_rwujlf3qh_g08 \
|
||||
m/ha6f0x7su6/gnz66h/9cwudvacx | tail -n1 >actual
|
||||
'
|
||||
|
||||
test_expect_success "ipfs add -w (repeats) is correct" '
|
||||
echo "$add_w_r" >expected &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
}
|
||||
|
||||
test_init_ipfs
|
||||
|
||||
test_add_w
|
||||
|
||||
test_launch_ipfs_daemon
|
||||
|
||||
test_add_w
|
||||
|
||||
test_kill_ipfs_daemon
|
||||
|
||||
test_done
|
Reference in New Issue
Block a user