service: get rid of bytefmt

- add ByteSize type + Stringer
- add test coverage
- cleanup modules

closes #22
This commit is contained in:
Evgeniy Kulikov 2019-11-26 15:48:55 +03:00
parent 999fcb5927
commit ac44e4bb9f
No known key found for this signature in database
GPG key ID: BF6AEE0A2A699BF2
4 changed files with 84 additions and 24 deletions

48
object/utils_test.go Normal file
View file

@ -0,0 +1,48 @@
package object
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestByteSize_String(t *testing.T) {
var cases = []struct {
name string
expect string
actual ByteSize
}{
{
name: "101 bytes",
expect: "101",
actual: ByteSize(101),
},
{
name: "112.84KB",
expect: "112.84KB",
actual: ByteSize(115548),
},
{
name: "80.44MB",
expect: "80.44MB",
actual: ByteSize(84347453),
},
{
name: "905.144GB",
expect: "905.144GB",
actual: ByteSize(971891061884),
},
{
name: "1.857TB",
expect: "1.857TB",
actual: ByteSize(2041793092780),
},
}
for i := range cases {
tt := cases[i]
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.expect, tt.actual.String())
})
}
}