Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

align output for the command ipfs object stat #6189

Merged
merged 1 commit into from
Apr 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion core/commands/object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,10 @@ var ObjectStatCmd = &cmds.Command{
Type: ipld.NodeStat{},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *ipld.NodeStat) error {
wtr := tabwriter.NewWriter(w, 0, 0, 1, ' ', 0)
defer wtr.Flush()
fw := func(s string, n int) {
fmt.Fprintf(w, "%s: %d\n", s, n)
fmt.Fprintf(wtr, "%s:\t%d\n", s, n)
}
fw("NumLinks", out.NumLinks)
fw("BlockSize", out.BlockSize)
Expand Down
18 changes: 9 additions & 9 deletions test/sharness/t0051-object.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ test_object_cmd() {
'

test_expect_success "'ipfs object get' output looks good" '
echo "NumLinks: 0" > expected_stat &&
echo "BlockSize: 18" >> expected_stat &&
echo "LinksSize: 2" >> expected_stat &&
echo "DataSize: 16" >> expected_stat &&
echo "NumLinks: 0" > expected_stat &&
echo "BlockSize: 18" >> expected_stat &&
echo "LinksSize: 2" >> expected_stat &&
echo "DataSize: 16" >> expected_stat &&
echo "CumulativeSize: 18" >> expected_stat &&
test_cmp expected_stat actual_stat
'
Expand Down Expand Up @@ -276,11 +276,11 @@ test_object_cmd() {
'

test_expect_success "ipfs object stat output looks good" '
echo NumLinks: 1 > obj_stat_exp &&
echo BlockSize: 47 >> obj_stat_exp &&
echo LinksSize: 45 >> obj_stat_exp &&
echo DataSize: 2 >> obj_stat_exp &&
echo CumulativeSize: 114 >> obj_stat_exp &&
echo "NumLinks: 1" > obj_stat_exp &&
echo "BlockSize: 47" >> obj_stat_exp &&
echo "LinksSize: 45" >> obj_stat_exp &&
echo "DataSize: 2" >> obj_stat_exp &&
echo "CumulativeSize: 114" >> obj_stat_exp &&

test_cmp obj_stat_exp obj_stat_out
'
Expand Down