test: share the first-page and clock helpers

writeFirstPage answers paged listings in app and services tests,
testNow replaces the copied clock, withoutANSI the second color
stripper, and the single-entry table test becomes a plain test.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 14:25:38 +02:00
1 parent 83924892ff
commit dc24231ebc
23 files changed
+66 -105

No files matched your search

+12
View File
@@ -19,6 +19,7 @@ import (
"regexp"
"strings"
"testing"
"time"
"gitea.dev/tea/internal/auth"
"gitea.dev/tea/internal/clierr"
@@ -336,3 +337,14 @@ func plainOutput(t *testing.T, deps Dependencies) {
return nil
}))
}
// writeFirstPage answers the first page of a listing with page and every later page with [].
func writeFirstPage(w http.ResponseWriter, r *http.Request, page string) {
if r.URL.Query().Get("page") != "1" {
page = `[]`
}
_, _ = w.Write([]byte(page))
}
// testNow is the clock of tests that show relative times.
var testNow = time.Date(2026, 10, 11, 20, 0, 0, 0, time.UTC)