forked from TrueCloudLab/frostfs-api-go
service: get rid of bytefmt
- add ByteSize type + Stringer - add test coverage - cleanup modules closes #22
This commit is contained in:
parent
999fcb5927
commit
ac44e4bb9f
4 changed files with 84 additions and 24 deletions
48
object/utils_test.go
Normal file
48
object/utils_test.go
Normal 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())
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue