1453cfc69b
gates / gates (push) Failing after 50s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
52 lines
2.1 KiB
Go
52 lines
2.1 KiB
Go
package web
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"gitea.dooplex.hu/admin/felhom-controller/internal/settings"
|
|
)
|
|
|
|
// R-365: with the abandonment's due moment PASSED but the daily sweep not yet run (up to ~29 h), the
|
|
// card read „A kérésed szerint a korábbi távoli mentéseidet 2026-08-20 napján véglegesen töröljük" on
|
|
// 2026-08-21 — a past date in the future tense. The consequence asserted, through the real handler and
|
|
// a real countdown read from settings: an overdue countdown renders the overdue sentence (due since the
|
|
// date, runs at the next daily maintenance) and not the future-tense one; a running countdown still
|
|
// renders the future-tense one (negative control).
|
|
func TestR365_OverdueCountdownIsNotFutureTense(t *testing.T) {
|
|
render := func(t *testing.T, due time.Time) string {
|
|
f := newRecoveryFixture(t)
|
|
if err := f.sett.SetOffboxTarget(&settings.OffboxTarget{
|
|
Enabled: true, Host: "nas.local", Port: 22, User: "felhom", RepoPath: "/srv/repo",
|
|
Schedule: "daily", EscrowState: "escrowed",
|
|
AbandonAt: due.UTC().Format(time.RFC3339), AbandonStartedAt: due.Add(-30 * 24 * time.Hour).UTC().Format(time.RFC3339),
|
|
}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
rr := httptest.NewRecorder()
|
|
f.s.backupsRemoteHandler(rr, httptest.NewRequest(http.MethodGet, "/backups/remote", nil))
|
|
if rr.Code != http.StatusOK {
|
|
t.Fatalf("status %d", rr.Code)
|
|
}
|
|
return rr.Body.String()
|
|
}
|
|
|
|
overdue := time.Now().Add(-20 * time.Hour)
|
|
html := render(t, overdue)
|
|
date := overdue.UTC().Format("2006-01-02")
|
|
if !strings.Contains(html, "óta esedékes") || !strings.Contains(html, date) {
|
|
t.Errorf("R-365: an overdue countdown does not say the deletion is due since %s", date)
|
|
}
|
|
if strings.Contains(html, "napján véglegesen töröljük") {
|
|
t.Errorf("R-365: an overdue countdown still renders a past date in the future tense")
|
|
}
|
|
|
|
running := render(t, time.Now().Add(3*24*time.Hour))
|
|
if !strings.Contains(running, "napján véglegesen töröljük") || strings.Contains(running, "óta esedékes") {
|
|
t.Errorf("a running countdown must keep the future-tense sentence")
|
|
}
|
|
}
|