Files
my-rook-config/pkg/util/display/bytes_test.go
T
Sébastien Han 871054e887 ceph: implement pod restriction on memory
If someone sets limits to pod, we want to ensure the possible
experience, so we want to make sure that people do not configure
inapropriate values for certain daemons.
We decide to fail if the memory.limit is too low.

Signed-off-by: Sébastien Han <seb@redhat.com>
2019-03-15 17:35:44 +01:00

42 lines
1.3 KiB
Go

/*
Copyright 2016 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package display
import (
"math"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBytesToString(t *testing.T) {
// one value for each unit
assert.Equal(t, "1 B", BytesToString(1))
assert.Equal(t, "1.00 KiB", BytesToString(1024))
assert.Equal(t, "2.22 MiB", BytesToString(2327839))
assert.Equal(t, "3.33 GiB", BytesToString(3575560274))
assert.Equal(t, "4.44 TiB", BytesToString(4881831627325))
assert.Equal(t, "5.55 PiB", BytesToString(6248744482976563))
assert.Equal(t, "6.66 EiB", BytesToString(7678457220681600860))
// min and max values
assert.Equal(t, "0 B", BytesToString(0))
assert.Equal(t, "16.00 EiB", BytesToString(math.MaxUint64))
assert.Equal(t, uint64(50), BToMb(uint64(52428800)))
assert.Equal(t, uint64(52428800), MbTob(uint64(50)))
}