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
4022d8b8
Commit
4022d8b8
authored
Oct 27, 2015
by
Juan Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1885 from ipfs/fix/ndjson
put newlines between streaming json output objects
parents
49684ea4
f130869b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
3 deletions
+42
-3
commands/response.go
commands/response.go
+1
-0
test/sharness/t0051-object-data/expected_getOut
test/sharness/t0051-object-data/expected_getOut
+1
-1
test/sharness/t0200-unixfs-ls.sh
test/sharness/t0200-unixfs-ls.sh
+2
-2
test/sharness/t0231-channel-streaming.sh
test/sharness/t0231-channel-streaming.sh
+38
-0
No files found.
commands/response.go
View file @
4022d8b8
...
...
@@ -47,6 +47,7 @@ func marshalJson(value interface{}) (io.Reader, error) {
if
err
!=
nil
{
return
nil
,
err
}
b
=
append
(
b
,
'\n'
)
return
bytes
.
NewReader
(
b
),
nil
}
...
...
test/sharness/t0051-object-data/expected_getOut
View file @
4022d8b8
test/sharness/t0200-unixfs-ls.sh
View file @
4022d8b8
...
...
@@ -122,7 +122,7 @@ test_ls_cmd() {
}
}
EOF
printf %s "$(cat expected_json_ls_file_trailing_newline)" >expected_json_ls_file &&
printf
"
%s
\n"
"$(cat expected_json_ls_file_trailing_newline)" >expected_json_ls_file &&
test_cmp expected_json_ls_file actual_json_ls_file
'
...
...
@@ -168,7 +168,7 @@ test_ls_cmd() {
}
}
EOF
printf %s "$(cat expected_json_ls_duplicates_file_trailing_newline)" >expected_json_ls_duplicates_file &&
printf
"
%s
\n"
"$(cat expected_json_ls_duplicates_file_trailing_newline)" >expected_json_ls_duplicates_file &&
test_cmp expected_json_ls_duplicates_file actual_json_ls_duplicates_file
'
}
...
...
test/sharness/t0231-channel-streaming.sh
0 → 100755
View file @
4022d8b8
#!/bin/sh
#
# Copyright (c) 2015 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#
test_description
=
"Test output of streaming json commands"
.
lib/test-lib.sh
test_init_ipfs
get_api_port
()
{
cat
"
$IPFS_PATH
/api"
|
awk
-F
/
'{ print $5 }'
}
test_ls_cmd
()
{
test_expect_success
"make a file with multiple refs"
'
HASH=$(random 1000000 | ipfs add -q)
'
test_expect_success
"can get refs through curl"
'
PORT=$(get_api_port) &&
curl http://localhost:$PORT/api/v0/refs/$HASH > output
'
# make sure newlines are printed between each object
test_expect_success
"output looks good"
'
test_expect_code 1 grep "}{" output > /dev/null
'
}
# should work online (only)
test_launch_ipfs_daemon
test_ls_cmd
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