CI / test (push) Successful in 5m35s
The errors other packages give a page (store, catalog, mirror) are shown in its language; a percentage is written as the language writes it (%93 in Turkish); the footer's time in its date form; and a stale form is refused with a sentence rather than "bad request". Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package web
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.mynodes.xyz/ilker/llmgw/internal/store"
|
|
)
|
|
|
|
// A Turkish page says the store's errors, percentages and moments the
|
|
// Turkish way, and a stale form plainly.
|
|
func TestATurkishPageSpeaksTurkishToTheEnd(t *testing.T) {
|
|
tr, en := langByCode("tr"), langByCode("en")
|
|
wrapped := fmt.Errorf("org Acme: %w", store.ErrNotEmpty)
|
|
if got := tr.Err(wrapped); !strings.Contains(got, "boş değil") {
|
|
t.Errorf("a wrapped store error in Turkish: %q", got)
|
|
}
|
|
if got := en.Err(store.ErrNotFound); !strings.Contains(got, "not there") {
|
|
t.Errorf("in English: %q", got)
|
|
}
|
|
if got := tr.Pct(93, 0); got != "%93" {
|
|
t.Errorf("Turkish percent %q", got)
|
|
}
|
|
if got := en.Pct(93.5, 1); got != "93.5%" {
|
|
t.Errorf("English percent %q", got)
|
|
}
|
|
stamp := tr.funcs()["stamp"].(func(string) string)
|
|
if got := stamp("2026-10-21T08:05:00Z"); got != "21.10.2026 08:05 UTC" {
|
|
t.Errorf("a Turkish moment %q", got)
|
|
}
|
|
rec := httptest.NewRecorder()
|
|
req := httptest.NewRequest(http.MethodPost, "/x", nil)
|
|
req.Header.Set("Accept-Language", "tr")
|
|
badForm(rec, req)
|
|
if rec.Code != http.StatusBadRequest || !strings.Contains(rec.Body.String(), "form süresi") {
|
|
t.Errorf("a stale form in Turkish: %d %q", rec.Code, rec.Body.String())
|
|
}
|
|
}
|