diff --git a/cmd/disks.go b/cmd/disks.go index 38ed4326a..c4b0c106e 100644 --- a/cmd/disks.go +++ b/cmd/disks.go @@ -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()), diff --git a/cmd/disks_test.go b/cmd/disks_test.go index 98778f1e4..ea3ce23f1 100644 --- a/cmd/disks_test.go +++ b/cmd/disks_test.go @@ -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"), diff --git a/ui/table/values.go b/ui/table/values.go index 2ac6b54c9..6e6d6aeb1 100644 --- a/ui/table/values.go +++ b/ui/table/values.go @@ -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 } diff --git a/ui/table/values_test.go b/ui/table/values_test.go index 0759c803c..423e175fd 100644 --- a/ui/table/values_test.go +++ b/ui/table/values_test.go @@ -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})) })