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
33f699f8
Commit
33f699f8
authored
Jun 26, 2017
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
files api: redo tests
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
parent
3f6a7b7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
54 deletions
+45
-54
test/sharness/t0250-files-api.sh
test/sharness/t0250-files-api.sh
+45
-54
No files found.
test/sharness/t0250-files-api.sh
View file @
33f699f8
...
...
@@ -10,18 +10,16 @@ test_description="test the unix files api"
test_init_ipfs
# setup files for testing
test_expect_success
"can create some files for testing"
'
FILE1=$(echo foo | ipfs add -q) &&
FILE2=$(echo bar | ipfs add -q) &&
FILE3=$(echo baz | ipfs add -q) &&
FILE9=$(echo zip | ipfs add -q --raw-leaves) &&
mkdir stuff_test &&
create_files
()
{
FILE1
=
$(
echo
foo | ipfs add
"
$@
"
-q
)
&&
FILE2
=
$(
echo
bar | ipfs add
"
$@
"
-q
)
&&
FILE3
=
$(
echo
baz | ipfs add
"
$@
"
-q
)
&&
mkdir
-p
stuff_test
&&
echo
cats
>
stuff_test/a
&&
echo
dogs
>
stuff_test/b
&&
echo
giraffes
>
stuff_test/c
&&
DIR1=$(ipfs add -q stuff_test | tail -n1)
'
DIR1
=
$(
ipfs add
-r
"
$@
"
-q
stuff_test |
tail
-n1
)
}
verify_path_exists
()
{
# simply running ls on a file should be a good 'check'
...
...
@@ -91,6 +89,8 @@ test_sharding() {
}
test_files_api
()
{
ROOT_HASH
=
$1
test_expect_success
"can mkdir in root"
'
ipfs files mkdir /cats
'
...
...
@@ -160,6 +160,12 @@ test_files_api() {
verify_dir_contents /cats file1
'
test_expect_success
"file has correct hash and size in directory"
'
echo "file1 $FILE1 4" > ls_l_expected &&
ipfs files ls -l /cats > ls_l_actual &&
test_cmp ls_l_expected ls_l_actual
'
test_expect_success
"can read file"
'
ipfs files read /cats/file1 > file1out
'
...
...
@@ -253,42 +259,6 @@ test_files_api() {
test_cmp roothash roothashafter
'
# test raw node
test_expect_success
"can put a raw-node into root"
'
ipfs files cp /ipfs/$FILE9 /file9
'
test_expect_success
"file shows up in root"
'
verify_dir_contents / file9 cats
'
test_expect_success
"can read file"
'
ipfs files read /file9 > file9out
'
test_expect_success
"output looks good"
'
echo zip > expected &&
test_cmp expected file9out
'
test_expect_success
"can remove file from root"
'
ipfs files rm /file9
'
test_expect_success
"file no longer appears"
'
verify_dir_contents / cats
'
test_expect_success
"check root hash"
'
ipfs files stat --hash / > roothash
'
test_expect_success
"check root hash was not changed"
'
ipfs files stat --hash / > roothashafter &&
test_cmp roothash roothashafter
'
# test read options
test_expect_success
"read from offset works"
'
...
...
@@ -439,7 +409,7 @@ test_files_api() {
test_expect_success
"root hash not bubbled up yet"
'
test -z "$ONLINE" ||
(ipfs refs local > refsout &&
test_expect_code 1 grep
QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt
refsout)
test_expect_code 1 grep
$ROOT_HASH
refsout)
'
test_expect_success
"changes bubbled up to root on inspection"
'
...
...
@@ -447,7 +417,7 @@ test_files_api() {
'
test_expect_success
"root hash looks good"
'
export EXP_ROOT_HASH="
QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt
" &&
export EXP_ROOT_HASH="
$ROOT_HASH
" &&
echo $EXP_ROOT_HASH > root_hash_exp &&
test_cmp root_hash_exp root_hash
'
...
...
@@ -558,26 +528,47 @@ test_files_api() {
ipfs files rm -r /foobar &&
ipfs files rm -r /adir
'
test_expect_success
"root mfs entry is empyt"
'
verify_dir_contents /
'
test_expect_success
"repo gc"
'
ipfs repo gc
'
}
# test offline and online
test_files_api
test_expect_success
"can create some files for testing"
'
create_files
'
test_files_api QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt
test_expect_success
"c
le
an
up objects from previous test run
"
'
ipfs repo gc
test_expect_success
"can
create some files for testing with raw-leaves
"
'
create_files --raw-leaves
'
test_files_api QmTpKiKcAj4sbeesN6vrs5w3QeVmd4QmGpxRL81hHut4dZ
test_launch_ipfs_daemon
test_launch_ipfs_daemon
--offline
ONLINE
=
1
# set online flag so tests can easily tell
test_files_api
test_kill_ipfs_daemon
test_expect_success
"can create some files for testing"
'
create_files
'
test_files_api QmcwKfTMCT7AaeiD92hWjnZn9b6eh9NxnhfSzN5x2vnDpt
test_expect_success
"can create some files for testing with raw-leaves"
'
create_files --raw-leaves
'
test_files_api QmTpKiKcAj4sbeesN6vrs5w3QeVmd4QmGpxRL81hHut4dZ
test_kill_ipfs_daemon
--offline
test_expect_success
"enable sharding in config"
'
ipfs config --json Experimental.ShardingEnabled true
'
test_launch_ipfs_daemon
test_launch_ipfs_daemon
--offline
test_sharding
test_kill_ipfs_daemon
...
...
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