2022-04-15 09:42:07 +02:00
|
|
|
package env
|
2020-05-05 15:42:54 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2022-04-15 09:42:07 +02:00
|
|
|
func TestNew(t *testing.T) {
|
|
|
|
info := Info()
|
2020-05-05 15:42:54 +02:00
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, info.Cores)
|
|
|
|
assert.LessOrEqual(t, 1, info.Routines)
|
2021-08-05 15:15:33 +02:00
|
|
|
assert.LessOrEqual(t, uint64(1), info.Memory.Total)
|
|
|
|
assert.LessOrEqual(t, uint64(1), info.Memory.Free)
|
2020-05-05 15:42:54 +02:00
|
|
|
assert.LessOrEqual(t, uint64(1), info.Memory.Reserved)
|
|
|
|
assert.LessOrEqual(t, uint64(1), info.Memory.Used)
|
2021-08-05 15:15:33 +02:00
|
|
|
|
|
|
|
// t.Logf("Free: %s, Total: %s", humanize.Bytes(info.Memory.Free), humanize.Bytes(info.Memory.Total))
|
2020-05-05 15:42:54 +02:00
|
|
|
}
|
|
|
|
|
2022-04-15 09:42:07 +02:00
|
|
|
func TestInfo_Update(t *testing.T) {
|
|
|
|
info := Info()
|
2020-05-05 15:42:54 +02:00
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, info.Cores)
|
|
|
|
assert.LessOrEqual(t, 1, info.Routines)
|
2021-08-05 15:15:33 +02:00
|
|
|
assert.LessOrEqual(t, uint64(1), info.Memory.Total)
|
|
|
|
assert.LessOrEqual(t, uint64(1), info.Memory.Free)
|
2020-05-05 15:42:54 +02:00
|
|
|
assert.LessOrEqual(t, uint64(1), info.Memory.Reserved)
|
|
|
|
assert.LessOrEqual(t, uint64(1), info.Memory.Used)
|
|
|
|
|
2022-04-15 09:42:07 +02:00
|
|
|
info.Update()
|
2020-05-05 15:42:54 +02:00
|
|
|
|
|
|
|
assert.LessOrEqual(t, 1, info.Cores)
|
|
|
|
assert.LessOrEqual(t, 1, info.Routines)
|
2021-08-05 15:15:33 +02:00
|
|
|
assert.LessOrEqual(t, uint64(1), info.Memory.Total)
|
|
|
|
assert.LessOrEqual(t, uint64(1), info.Memory.Free)
|
2020-05-05 15:42:54 +02:00
|
|
|
assert.LessOrEqual(t, uint64(1), info.Memory.Reserved)
|
|
|
|
assert.LessOrEqual(t, uint64(1), info.Memory.Used)
|
|
|
|
}
|