R-575: the overcommit warning follows the reader's language

memoryVerdict returns the warning's bundle KEY (KeyMemoryOvercommitWarning)
and DeployStack hands it on; the API renders it per request
(deployWarningData). msgHU, whose only use this was, is gone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
2026-10-05 22:42:21 +02:00
parent b36a85ac04
commit b05be0ac11
5 changed files with 81 additions and 26 deletions
@@ -0,0 +1,32 @@
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)
}
}