Commit 76e8190a authored by Kejie Zhang's avatar Kejie Zhang

drop --name test file and update test case

License: MIT
Signed-off-by: default avatarKejie Zhang <601172892@qq.com>
parent ad27614a
......@@ -184,6 +184,27 @@ test_add_cat_file() {
test_expect_success "make sure it looks good" '
test_cmp zero-length-file zero-length-file_out
'
test_expect_success "ipfs add --name" '
HASH="QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w" &&
echo "IPFS" | ipfs add --name file.txt > actual &&
echo "added $HASH file.txt" > expected &&
test_cmp expected actual
'
test_expect_success "ipfs add --name -w" '
HASH1="QmdFyxZXsFiP4csgfM5uPu99AvFiKH62CSPDw5TP92nr7w" &&
echo "IPFS" | ipfs add -w --name file.txt | head -n1> actual &&
echo "added $HASH1 file.txt" > expected &&
test_cmp expected actual
'
test_expect_success "ipfs cat with name" '
HASH=$(echo "IPFS" | ipfs add -w --name file.txt -Q) &&
ipfs cat /ipfs/$HASH/file.txt > expected &&
echo "IPFS" > actual &&
test_cmp expected actual
'
}
test_add_cat_5MB() {
......
#!/usr/bin/env bash
#
# Copyright (c) 2018 Kejie Zhang
# MIT Licensed; see the LICENSE file in this repository.
#
test_description="Test add --name"
add_name_m='QmazHkwx6mPmmCEi1jR5YzjjQd1g5XzKfYQLzRAg7x5uUk'
add_name_1='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu 4r93'
add_name_2='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu 4r93
added Qmf82PSsMpUHcrqxa69KG6Qp5yeK7K9BTizXgG3nvzWcNG '
add_name_3='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu myfile.txt
added QmZbStPUUoRr1hA9GZyKx7pyskZvCczPrf6XSK6A9HSr1i '
add_name_4='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu myfile.txt'
. lib/test-lib.sh
test_add_name() {
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_name_m" >expected &&
ipfs add -q -r m | tail -n1 >actual &&
echo $actual
test_sort_cmp expected actual
'
# test --name without -w
test_expect_success "ipfs add --name is correct" '
echo "$add_name_1" >expected &&
ipfs add m/4r93 --name myfile.txt >actual
test_sort_cmp expected actual
'
# test --name with -w
test_expect_success "ipfs add -w --name is correct" '
echo "$add_name_2" >expected &&
ipfs add m/4r93 -w --name myfile.txt >actual
test_sort_cmp expected actual
'
# test --name with -w and cat
test_expect_success "cat file | ipfs add -w --name is correct" '
echo "$add_name_3" >expected &&
cat m/4r93 | ipfs add -w --name myfile.txt >actual
test_sort_cmp expected actual
'
# test --name with cat but without -w
test_expect_success "cat file | ipfs add --name is correct" '
echo "$add_name_4" >expected &&
cat m/4r93 | ipfs add --name myfile.txt >actual
test_sort_cmp expected actual
'
}
test_init_ipfs
test_add_name
test_launch_ipfs_daemon
test_add_name
test_kill_ipfs_daemon
test_done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment