Skip to content

Commit

Permalink
fix disk -o command to show size in mb
Browse files Browse the repository at this point in the history
  • Loading branch information
tjvman committed Sep 2, 2016
1 parent 7009ff3 commit 4a29d82
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (c DisksCmd) Run(opts DisksOpts) error {
for _, d := range disks {
table.Rows = append(table.Rows, []boshtbl.Value{
boshtbl.NewValueString(d.CID()),
boshtbl.NewValueBytes(d.Size()),
boshtbl.NewValueMegaBytes(d.Size()),
boshtbl.NewValueString(d.Deployment().Name()),
boshtbl.NewValueString(d.InstanceName()),
boshtbl.NewValueString(d.AZName()),
Expand Down
2 changes: 1 addition & 1 deletion cmd/disks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var _ = Describe("DisksCmd", func() {
Rows: [][]boshtbl.Value{
{
boshtbl.NewValueString("cid"),
boshtbl.NewValueBytes(100),
boshtbl.NewValueMegaBytes(100),
boshtbl.NewValueString("deployment"),
boshtbl.NewValueString("instance"),
boshtbl.NewValueString("az"),
Expand Down
3 changes: 2 additions & 1 deletion ui/table/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ func (t ValueInt) Compare(other Value) int {
}
}

func NewValueBytes(i uint64) ValueBytes { return ValueBytes{I: i} }
func NewValueBytes(i uint64) ValueBytes { return ValueBytes{I: i} }
func NewValueMegaBytes(i uint64) ValueBytes { return ValueBytes{I: i * 1024 * 1024} }

func (t ValueBytes) String() string { return humanize.Bytes(t.I) }
func (t ValueBytes) Value() Value { return t }
Expand Down
4 changes: 4 additions & 0 deletions ui/table/values_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ var _ = Describe("ValueBytes", func() {
Expect(ValueBytes{1}.String()).To(Equal("1 B"))
})

It("returns formatted megabytes", func() {
Expect(NewValueMegaBytes(1).String()).To(Equal("1.0 MB"))
})

It("returns itself", func() {
Expect(ValueBytes{1}.Value()).To(Equal(ValueBytes{1}))
})
Expand Down

0 comments on commit 4a29d82

Please sign in to comment.