package api import ( "net/http/httptest" "strings" "testing" "gitea.dooplex.hu/admin/felhom-controller/internal/stacks" ) // R-575: the deploy answer renders the overcommit warning in the reader's language — English for an // English request (it used to be Hungarian on every page), Hungarian by default. func TestR575_OvercommitWarningFollowsTheLanguage(t *testing.T) { r := &Router{} en := r.deployWarningData(httptest.NewRequest("POST", "/api/stacks/x/deploy?lang=en", nil), stacks.KeyMemoryOvercommitWarning) hu := r.deployWarningData(httptest.NewRequest("POST", "/api/stacks/x/deploy?lang=hu", nil), stacks.KeyMemoryOvercommitWarning) if en == nil || hu == nil { t.Fatal("a warning key must produce a warning") } if !strings.Contains(en["warning"], "memory") || strings.Contains(en["warning"], "memóri") { t.Errorf("English page got %q", en["warning"]) } if !strings.Contains(hu["warning"], "memóri") { t.Errorf("Hungarian page got %q", hu["warning"]) } if strings.Contains(en["warning"], "err.stacks.") || strings.Contains(hu["warning"], "err.stacks.") { t.Error("a raw key reached the page") } if d := r.deployWarningData(httptest.NewRequest("POST", "/", nil), ""); d != nil { t.Errorf("no warning -> no data, got %v", d) } }