25 lines
585 B
Go
25 lines
585 B
Go
package local
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"slackerbot/internal/model"
|
|
)
|
|
|
|
func TestCapacity(t *testing.T) {
|
|
c := Capacity{Usable: model.Size{MemoryMB: 6144, CPUs: 3}}
|
|
def := model.Size{MemoryMB: 2048, CPUs: 1}
|
|
if got := c.Slots(def); got != 3 {
|
|
t.Fatalf("slots = %d, want 3", got)
|
|
}
|
|
if !c.Room(model.Size{MemoryMB: 4096, CPUs: 2}, def) {
|
|
t.Fatal("third container should fit")
|
|
}
|
|
if c.Room(model.Size{MemoryMB: 6144, CPUs: 3}, def) {
|
|
t.Fatal("fourth container should not fit")
|
|
}
|
|
if c.Room(model.Size{MemoryMB: 2048, CPUs: 2.5}, def) {
|
|
t.Fatal("should be blocked by CPU")
|
|
}
|
|
}
|