Skip to content

Commit

Permalink
Merge pull request #6189 from myself659/ipfs-object-stat
Browse files Browse the repository at this point in the history
align output for the command ipfs object stat
  • Loading branch information
Stebalien authored Apr 6, 2019
2 parents 8c1d89a + e5ef537 commit c91e075
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
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

0 comments on commit c91e075

Please sign in to comment.