Files
felhom.eu/hub/internal/web/d83_small_disk_test.go
T

43 lines
1.6 KiB
Go

package web
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
"gitea.dooplex.hu/admin/felhom-hub/internal/store"
)
// D83 (R-1398 part 2): the box's page says when the box was accepted on a small system disk — and says NOTHING for a
// box the hub was never told about (an older installer, or a disk of 200 GB or more). One render per branch.
func TestD83_HostPageShowsTheSmallDiskLine(t *testing.T) {
s, st := newTestServer(t)
for _, h := range []string{"small-1", "small-2", "plain-1"} {
if err := st.UpsertHost(&store.Host{HostID: h, CustomerID: "c1", APIKey: "k-" + h}); err != nil {
t.Fatal(err)
}
}
at := time.Date(2026, 11, 16, 9, 0, 0, 0, time.UTC)
_ = st.NoteSmallDisk("small-1", 128035676160, at)
_ = st.NoteSmallDisk("small-2", 0, at)
page := func(id string) string {
rr := httptest.NewRecorder()
s.handleHostDetail(rr, httptest.NewRequest(http.MethodGet, "/hosts/"+id, nil), id)
if rr.Code != http.StatusOK {
t.Fatalf("%s: status %d", id, rr.Code)
}
return rr.Body.String()
}
if b := page("small-1"); !strings.Contains(b, `id="small-disk"`) || !strings.Contains(b, "accepted below 200 GB (128 GB, noted 2026-11-16)") {
t.Fatalf("the page of a box accepted on 128 GB does not say so")
}
if b := page("small-2"); !strings.Contains(b, "accepted below 200 GB (size not told, noted 2026-11-16)") {
t.Fatalf("the page of a box whose installer sent no size does not say „size not told”")
}
if b := page("plain-1"); strings.Contains(b, `id="small-disk"`) || strings.Contains(b, "accepted below 200 GB") {
t.Fatalf("the page of a box the hub was never told about shows the small-disk line")
}
}