@cryptotaxi247 / kubo / commits / a4e72871f

add tests for symlinks

License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>

Jeromy committed Sep 2, 2015 at 12:59 UTC a4e72871fa1ec2d8508cc6e7c75c2b48e01e5662
1 file changed +58
test/sharness/t0044-add-symlink.sh new
+58
@@ -0,0 +1,58 @@
1 +#!/bin/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 | tail -n 1 > filehash_out
22 + '
23 +
24 + test_expect_success "output looks good" '
25 + echo QmWdiHKoeSW8G1u7ATCgpx4yMoUhYaJBQGkyPLkS9goYZ8 > filehash_exp &&
26 + test_cmp filehash_out filehash_exp
27 + '
28 +
29 + test_expect_success "adding a symlink adds the link itself" '
30 + ipfs add -q files/bar/baz > goodlink_out
31 + '
32 +
33 + test_expect_success "output looks good" '
34 + echo "QmdocmZeF7qwPT9Z8SiVhMSyKA2KKoA2J7jToW6z6WBmxR" > goodlink_exp &&
35 + test_cmp goodlink_out goodlink_exp
36 + '
37 +
38 + test_expect_success "adding a broken symlink works" '
39 + ipfs add -q files/bad > badlink_out
40 + '
41 +
42 + test_expect_success "output looks good" '
43 + echo "QmWYN8SEXCgNT2PSjB6BnxAx6NJQtazWoBkTRH9GRfPFFQ" > badlink_exp &&
44 + test_cmp badlink_out badlink_exp
45 + '
46 +}
47 +
48 +test_init_ipfs
49 +
50 +test_add_symlinks
51 +
52 +test_launch_ipfs_daemon
53 +
54 +test_add_symlinks
55 +
56 +test_kill_ipfs_daemon
57 +
58 +test_done