@cryptotaxi247 / kubo / commits / ad27614a6

add sharness tests for --name option

License: MIT Signed-off-by: Kejie Zhang <601172892@qq.com>

Kejie Zhang committed Sep 6, 2018 at 15:01 UTC ad27614a6631aec1a32126cf951e7c3f2d560ed6
1 file changed +76
test/sharness/t0047-add-name.sh new
+76
@@ -0,0 +1,76 @@
1 +#!/usr/bin/env bash
2 +#
3 +# Copyright (c) 2018 Kejie Zhang
4 +# MIT Licensed; see the LICENSE file in this repository.
5 +#
6 +
7 +test_description="Test add --name"
8 +
9 +add_name_m='QmazHkwx6mPmmCEi1jR5YzjjQd1g5XzKfYQLzRAg7x5uUk'
10 +
11 +add_name_1='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu 4r93'
12 +
13 +add_name_2='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu 4r93
14 +added Qmf82PSsMpUHcrqxa69KG6Qp5yeK7K9BTizXgG3nvzWcNG '
15 +
16 +add_name_3='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu myfile.txt
17 +added QmZbStPUUoRr1hA9GZyKx7pyskZvCczPrf6XSK6A9HSr1i '
18 +
19 +add_name_4='added Qme987pqNBhZZXy4ckeXiR7zaRQwBabB7fTgHurW2yJfNu myfile.txt'
20 +
21 +. lib/test-lib.sh
22 +
23 +test_add_name() {
24 +
25 + test_expect_success "go-random-files is installed" '
26 + type random-files
27 + '
28 +
29 + test_expect_success "random-files generates test files" '
30 + random-files --seed 7547632 --files 5 --dirs 2 --depth 3 m &&
31 + echo "$add_name_m" >expected &&
32 + ipfs add -q -r m | tail -n1 >actual &&
33 + echo $actual
34 + test_sort_cmp expected actual
35 + '
36 +
37 + # test --name without -w
38 + test_expect_success "ipfs add --name is correct" '
39 + echo "$add_name_1" >expected &&
40 + ipfs add m/4r93 --name myfile.txt >actual
41 + test_sort_cmp expected actual
42 + '
43 +
44 + # test --name with -w
45 + test_expect_success "ipfs add -w --name is correct" '
46 + echo "$add_name_2" >expected &&
47 + ipfs add m/4r93 -w --name myfile.txt >actual
48 + test_sort_cmp expected actual
49 + '
50 +
51 + # test --name with -w and cat
52 + test_expect_success "cat file | ipfs add -w --name is correct" '
53 + echo "$add_name_3" >expected &&
54 + cat m/4r93 | ipfs add -w --name myfile.txt >actual
55 + test_sort_cmp expected actual
56 + '
57 +
58 + # test --name with cat but without -w
59 + test_expect_success "cat file | ipfs add --name is correct" '
60 + echo "$add_name_4" >expected &&
61 + cat m/4r93 | ipfs add --name myfile.txt >actual
62 + test_sort_cmp expected actual
63 + '
64 +}
65 +
66 +test_init_ipfs
67 +
68 +test_add_name
69 +
70 +test_launch_ipfs_daemon
71 +
72 +test_add_name
73 +
74 +test_kill_ipfs_daemon
75 +
76 +test_done