Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
04482cbe
Commit
04482cbe
authored
Sep 07, 2015
by
Matt Bell
Committed by
rht
Oct 13, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consolidated 'resolve' tests
License: MIT Signed-off-by:
Matt Bell
<
mappum@gmail.com
>
parent
dd8267b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
67 deletions
+45
-67
test/sharness/t0101-resolve.sh
test/sharness/t0101-resolve.sh
+0
-55
test/sharness/t0160-resolve.sh
test/sharness/t0160-resolve.sh
+45
-12
No files found.
test/sharness/t0101-resolve.sh
deleted
100755 → 0
View file @
dd8267b9
#!/bin/sh
#
# Copyright (c) 2015 Matt Bell
# MIT Licensed; see the LICENSE file in this repository.
#
test_description
=
"Test ipfs resolve operations"
.
lib/test-lib.sh
test_init_ipfs
# setup
test_expect_success
"setup: add files"
'
mkdir mountdir/foodir &&
echo "Hello Mars!" >mountdir/foodir/mars.txt &&
echo "/ipfs/`ipfs add -q mountdir/foodir/mars.txt`" >filehash &&
ipfs add -q -r mountdir/foodir | tail -n 1 >dirhash
'
test_expect_success
"setup: get IPFS ID"
'
ID=`ipfs id --format="<id>\n"`
'
# resolve an IPNS name to a simple /ipfs/ path
test_expect_success
"setup: publish file to IPNS name"
'
ipfs name publish `cat filehash`
'
test_expect_success
"'ipfs resolve' succeeds with IPNS->path"
'
echo `ipfs resolve "/ipns/$ID"` >actual
'
test_expect_success
"'ipfs resolve' output looks good"
'
test_cmp filehash actual
'
# resolve an IPNS name to a /ipfs/HASH/link/name path
test_expect_success
"setup: publish link path to IPNS name"
'
ipfs name publish "`cat dirhash`/mars.txt"
'
test_expect_success
"'ipfs resolve' succeeds with IPNS->link path"
'
echo `ipfs resolve "/ipns/$ID"` >actual
'
test_expect_success
"'ipfs resolve' output looks good"
'
test_cmp filehash actual
'
test_done
test/sharness/t0160-resolve.sh
View file @
04482cbe
...
...
@@ -14,20 +14,36 @@ test_expect_success "resolve: prepare files" '
c_hash=$(ipfs add -q -r a/b/c | tail -n1)
'
test_expect_success
"resolve: prepare name"
'
id_hash=$(ipfs id -f="<id>") &&
ipfs name publish "$a_hash" &&
printf "/ipfs/$a_hash" >expected_nameval &&
ipfs name resolve >actual_nameval &&
test_cmp expected_nameval actual_nameval
'
test_resolve_setup_name
()
{
ref
=
$1
test_expect_success
"resolve: prepare name"
'
id_hash=$(ipfs id -f="<id>") &&
ipfs name publish "$ref" &&
printf "$ref" >expected_nameval &&
ipfs name resolve >actual_nameval &&
test_cmp expected_nameval actual_nameval
'
}
test_resolve_setup_name_fail
()
{
ref
=
$1
test_expect_failure
"resolve: prepare name"
'
id_hash=$(ipfs id -f="<id>") &&
ipfs name publish "$ref" &&
printf "$ref" >expected_nameval &&
ipfs name resolve >actual_nameval &&
test_cmp expected_nameval actual_nameval
'
}
test_resolve
()
{
src
=
$1
dst
=
$2
test_expect_success
"resolve succeeds:
$src
"
'
ipfs resolve "$src" >actual
ipfs resolve
-r
"$src" >actual
'
test_expect_success
"resolved correctly:
$src
->
$dst
"
'
...
...
@@ -41,10 +57,19 @@ test_resolve_cmd() {
test_resolve
"/ipfs/
$a_hash
"
"/ipfs/
$a_hash
"
test_resolve
"/ipfs/
$a_hash
/b"
"/ipfs/
$b_hash
"
test_resolve
"/ipfs/
$a_hash
/b/c"
"/ipfs/
$c_hash
"
test_resolve
"/ipfs/
$b_hash
/c"
"/ipfs/
$c_hash
"
test_resolve_setup_name
"/ipfs/
$a_hash
"
test_resolve
"/ipns/
$id_hash
"
"/ipfs/
$a_hash
"
test_resolve
"/ipns/
$id_hash
/b"
"/ipfs/
$b_hash
"
test_resolve
"/ipns/
$id_hash
/b/c"
"/ipfs/
$c_hash
"
test_resolve_setup_name
"/ipfs/
$b_hash
"
test_resolve
"/ipns/
$id_hash
"
"/ipfs/
$b_hash
"
test_resolve
"/ipns/
$id_hash
/c"
"/ipfs/
$c_hash
"
test_resolve_setup_name
"/ipfs/
$c_hash
"
test_resolve
"/ipns/
$id_hash
"
"/ipfs/
$c_hash
"
}
#todo remove this once the online resolve is fixed
...
...
@@ -63,14 +88,22 @@ test_resolve_fail() {
}
test_resolve_cmd_fail
()
{
test_resolve
"/ipfs/
$a_hash
"
"/ipfs/
$a_hash
"
test_resolve
"/ipfs/
$a_hash
/b"
"/ipfs/
$b_hash
"
test_resolve
"/ipfs/
$a_hash
/b/c"
"/ipfs/
$c_hash
"
test_resolve
"/ipfs/
$b_hash
/c"
"/ipfs/
$c_hash
"
test_resolve_fail
"/ipfs/
$a_hash
"
"/ipfs/
$a_hash
"
test_resolve_fail
"/ipfs/
$a_hash
/b"
"/ipfs/
$b_hash
"
test_resolve_fail
"/ipfs/
$a_hash
/b/c"
"/ipfs/
$c_hash
"
test_resolve_setup_name_fail
"/ipfs/
$a_hash
"
test_resolve_fail
"/ipns/
$id_hash
"
"/ipfs/
$a_hash
"
test_resolve_fail
"/ipns/
$id_hash
/b"
"/ipfs/
$b_hash
"
test_resolve_fail
"/ipns/
$id_hash
/b/c"
"/ipfs/
$c_hash
"
test_resolve_setup_name_fail
"/ipfs/
$b_hash
"
test_resolve_fail
"/ipns/
$id_hash
"
"/ipfs/
$b_hash
"
test_resolve_fail
"/ipns/
$id_hash
/c"
"/ipfs/
$c_hash
"
test_resolve_setup_name_fail
"/ipfs/
$c_hash
"
test_resolve_fail
"/ipns/
$id_hash
"
"/ipfs/
$c_hash
"
}
# should work offline
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment