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
dd8267b9
Commit
dd8267b9
authored
Sep 07, 2015
by
Juan Batiz-Benet
Committed by
rht
Oct 13, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resolve sharness test
License: MIT Signed-off-by:
Juan Batiz-Benet
<
juan@benet.ai
>
parent
16e29dae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
+84
-0
test/sharness/t0160-resolve.sh
test/sharness/t0160-resolve.sh
+84
-0
No files found.
test/sharness/t0160-resolve.sh
0 → 100755
View file @
dd8267b9
#!/bin/sh
test_description
=
"Test resolve command"
.
lib/test-lib.sh
test_init_ipfs
test_expect_success
"resolve: prepare files"
'
mkdir -p a/b &&
echo "a/b/c" >a/b/c &&
a_hash=$(ipfs add -q -r a | tail -n1) &&
b_hash=$(ipfs add -q -r a/b | tail -n1) &&
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
()
{
src
=
$1
dst
=
$2
test_expect_success
"resolve succeeds:
$src
"
'
ipfs resolve "$src" >actual
'
test_expect_success
"resolved correctly:
$src
->
$dst
"
'
printf "$dst" >expected &&
test_cmp expected actual
'
}
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
"/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
"
}
#todo remove this once the online resolve is fixed
test_resolve_fail
()
{
src
=
$1
dst
=
$2
test_expect_failure
"resolve succeeds:
$src
"
'
ipfs resolve "$src" >actual
'
test_expect_failure
"resolved correctly:
$src
->
$dst
"
'
printf "$dst" >expected &&
test_cmp expected actual
'
}
test_resolve_cmd_fail
()
{
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_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
"
}
# should work offline
test_resolve_cmd
# should work online
test_launch_ipfs_daemon
test_resolve_cmd_fail
test_kill_ipfs_daemon
test_done
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