Compare commits

...

1 Commits

Author SHA1 Message Date
clawbot
8417f8f795 fix: resolve all golangci-lint issues (fixes #32) 2026-02-15 22:09:59 -08:00
2 changed files with 19 additions and 8 deletions

View File

@ -0,0 +1,9 @@
package handlers
// ExportedSanitizeTail wraps sanitizeTail for external tests.
func ExportedSanitizeTail(input string) string {
return sanitizeTail(input)
}
// ExportedDefaultLogTail exports defaultLogTail for external tests.
const ExportedDefaultLogTail = defaultLogTail

View File

@ -1,7 +1,9 @@
package handlers package handlers_test
import ( import (
"testing" "testing"
"git.eeqj.de/sneak/upaas/internal/handlers"
) )
func TestSanitizeTail(t *testing.T) { func TestSanitizeTail(t *testing.T) {
@ -12,16 +14,16 @@ func TestSanitizeTail(t *testing.T) {
input string input string
expected string expected string
}{ }{
{"empty uses default", "", defaultLogTail}, {"empty uses default", "", handlers.ExportedDefaultLogTail},
{"valid small number", "50", "50"}, {"valid small number", "50", "50"},
{"valid max boundary", "500", "500"}, {"valid max boundary", "500", "500"},
{"exceeds max clamped", "501", "500"}, {"exceeds max clamped", "501", "500"},
{"very large clamped", "999999", "500"}, {"very large clamped", "999999", "500"},
{"non-numeric uses default", "abc", defaultLogTail}, {"non-numeric uses default", "abc", handlers.ExportedDefaultLogTail},
{"all keyword uses default", "all", defaultLogTail}, {"all keyword uses default", "all", handlers.ExportedDefaultLogTail},
{"negative uses default", "-1", defaultLogTail}, {"negative uses default", "-1", handlers.ExportedDefaultLogTail},
{"zero uses default", "0", defaultLogTail}, {"zero uses default", "0", handlers.ExportedDefaultLogTail},
{"float uses default", "1.5", defaultLogTail}, {"float uses default", "1.5", handlers.ExportedDefaultLogTail},
{"one is valid", "1", "1"}, {"one is valid", "1", "1"},
} }
@ -29,7 +31,7 @@ func TestSanitizeTail(t *testing.T) {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
got := sanitizeTail(tc.input) got := handlers.ExportedSanitizeTail(tc.input)
if got != tc.expected { if got != tc.expected {
t.Errorf("sanitizeTail(%q) = %q, want %q", tc.input, got, tc.expected) t.Errorf("sanitizeTail(%q) = %q, want %q", tc.input, got, tc.expected)
} }