@cryptotaxi247 / kubo / commits / 16e29dae7

sharness: Added tests for 'ipfs resolve'

License: MIT Signed-off-by: Matt Bell <mappum@gmail.com>

Matt Bell committed Sep 6, 2015 at 16:48 UTC 16e29dae77941d51847c8b03c1c868cab914fedb
1 file changed +55
test/sharness/t0101-resolve.sh new
+55
@@ -0,0 +1,55 @@
1 +#!/bin/sh
2 +#
3 +# Copyright (c) 2015 Matt Bell
4 +# MIT Licensed; see the LICENSE file in this repository.
5 +#
6 +
7 +test_description="Test ipfs resolve operations"
8 +
9 +. lib/test-lib.sh
10 +
11 +test_init_ipfs
12 +
13 +# setup
14 +
15 +test_expect_success "setup: add files" '
16 + mkdir mountdir/foodir &&
17 + echo "Hello Mars!" >mountdir/foodir/mars.txt &&
18 + echo "/ipfs/`ipfs add -q mountdir/foodir/mars.txt`" >filehash &&
19 + ipfs add -q -r mountdir/foodir | tail -n 1 >dirhash
20 +'
21 +
22 +test_expect_success "setup: get IPFS ID" '
23 + ID=`ipfs id --format="<id>\n"`
24 +'
25 +
26 +# resolve an IPNS name to a simple /ipfs/ path
27 +
28 +test_expect_success "setup: publish file to IPNS name" '
29 + ipfs name publish `cat filehash`
30 +'
31 +
32 +test_expect_success "'ipfs resolve' succeeds with IPNS->path" '
33 + echo `ipfs resolve "/ipns/$ID"` >actual
34 +'
35 +
36 +test_expect_success "'ipfs resolve' output looks good" '
37 + test_cmp filehash actual
38 +'
39 +
40 +# resolve an IPNS name to a /ipfs/HASH/link/name path
41 +
42 +test_expect_success "setup: publish link path to IPNS name" '
43 + ipfs name publish "`cat dirhash`/mars.txt"
44 +'
45 +
46 +test_expect_success "'ipfs resolve' succeeds with IPNS->link path" '
47 + echo `ipfs resolve "/ipns/$ID"` >actual
48 +'
49 +
50 +test_expect_success "'ipfs resolve' output looks good" '
51 + test_cmp filehash actual
52 +'
53 +
54 +
55 +test_done