Files
felhom-controller/controller/internal/web/r1192_swap_short_test.go
T

29 lines
1.1 KiB
Go

package web
import (
"testing"
"gitea.dooplex.hu/admin/felhom-controller/internal/agentapi"
)
// R-1192 follow-up (night 2026-10-21): the install page adds „A gépen nincs elég cserehely (swap)…" when memory is
// tight AND the agent reports the host's swap below the guest's RAM. An older agent (no number) is not judged.
// RED-PROOF: swapShort returning false always → the first case fails.
func TestR1192_SwapShortJudgesTheHostSwapAgainstTheGuestRAM(t *testing.T) {
mb := func(v int64) *int64 { return &v }
for _, c := range []struct {
name string
info agentapi.GuestMemoryInfo
want bool
}{
{"a host with no swap", agentapi.GuestMemoryInfo{AllocatedMB: 4096, HostSwapMB: mb(0)}, true},
{"a host with 2 GB swap behind a 4 GB guest", agentapi.GuestMemoryInfo{AllocatedMB: 4096, HostSwapMB: mb(2048)}, true},
{"the installer's 8 GB host (7.75 GB swap)", agentapi.GuestMemoryInfo{AllocatedMB: 4096, HostSwapMB: mb(7935)}, false},
{"an older agent (no number)", agentapi.GuestMemoryInfo{AllocatedMB: 4096}, false},
} {
if got := swapShort(c.info); got != c.want {
t.Errorf("%s: swapShort = %v, want %v", c.name, got, c.want)
}
}
}