master
sh 78 lines 1.95 KB
Raw
1 #!/usr/bin/env bash
2 #
3 # Copyright (c) 2014 Christian Couder
4 # MIT Licensed; see the LICENSE file in this repository.
5 #
6
7 test_description="Test add -w"
8
9 . lib/test-lib.sh
10
11 test_expect_success "creating files succeeds" '
12 mkdir -p files/foo &&
13 mkdir -p files/bar &&
14 echo "some text" > files/foo/baz &&
15 ln -s files/foo/baz files/bar/baz &&
16 ln -s files/does/not/exist files/bad
17 '
18
19 test_add_symlinks() {
20 test_expect_success "ipfs add files succeeds" '
21 ipfs add -Q -r files >filehash_out
22 '
23
24 test_expect_success "output looks good" '
25 echo QmWdiHKoeSW8G1u7ATCgpx4yMoUhYaJBQGkyPLkS9goYZ8 > filehash_exp &&
26 test_cmp filehash_exp filehash_out
27 '
28
29 test_expect_success "ipfs add --cid-version=1 files succeeds" '
30 ipfs add -Q -r --cid-version=1 files >filehash_out
31 '
32
33 test_expect_success "output looks good" '
34 # note this hash implies all internal nodes are stored using CidV1
35 echo bafybeibyhlx64cklod6isy3h7tsmr4qvam3ae3b74n3hfes5bythjrwyua > filehash_exp &&
36 test_cmp filehash_exp filehash_out
37 '
38
39 test_expect_success "adding a symlink adds the link itself" '
40 ipfs add -q files/bar/baz > goodlink_out
41 '
42
43 test_expect_success "output looks good" '
44 echo "QmdocmZeF7qwPT9Z8SiVhMSyKA2KKoA2J7jToW6z6WBmxR" > goodlink_exp &&
45 test_cmp goodlink_exp goodlink_out
46 '
47
48 test_expect_success "adding a broken symlink works" '
49 ipfs add -q files/bad > badlink_out
50 '
51
52 test_expect_success "output looks good" '
53 echo "QmWYN8SEXCgNT2PSjB6BnxAx6NJQtazWoBkTRH9GRfPFFQ" > badlink_exp &&
54 test_cmp badlink_exp badlink_out
55 '
56
57 test_expect_success "adding with symlink in middle of path is same as\
58 adding with no symlink" '
59 mkdir -p files2/a/b/c &&
60 echo "some other text" > files2/a/b/c/foo &&
61 ln -s b files2/a/d
62 ipfs add -rq files2/a/b/c > no_sym &&
63 ipfs add -rq files2/a/d/c > sym &&
64 test_cmp no_sym sym
65 '
66 }
67
68 test_init_ipfs
69
70 test_add_symlinks
71
72 test_launch_ipfs_daemon
73
74 test_add_symlinks
75
76 test_kill_ipfs_daemon
77
78 test_done