Files
upaas/internal/handlers/tail_validation_test.go
user f4a407dda3
All checks were successful
Check / check (pull_request) Successful in 2m33s
fix: change module path to sneak.berlin/go/upaas (fixes #143)
2026-02-26 05:58:19 -08:00

41 lines
1016 B
Go

package handlers_test
import (
"testing"
"sneak.berlin/go/upaas/internal/handlers"
)
func TestSanitizeTail(t *testing.T) {
t.Parallel()
tests := []struct {
name string
input string
expected string
}{
{"empty uses default", "", handlers.DefaultLogTail},
{"valid small number", "50", "50"},
{"valid max boundary", "500", "500"},
{"exceeds max clamped", "501", "500"},
{"very large clamped", "999999", "500"},
{"non-numeric uses default", "abc", handlers.DefaultLogTail},
{"all keyword uses default", "all", handlers.DefaultLogTail},
{"negative uses default", "-1", handlers.DefaultLogTail},
{"zero uses default", "0", handlers.DefaultLogTail},
{"float uses default", "1.5", handlers.DefaultLogTail},
{"one is valid", "1", "1"},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
got := handlers.SanitizeTail(tc.input)
if got != tc.expected {
t.Errorf("sanitizeTail(%q) = %q, want %q", tc.input, got, tc.expected)
}
})
}
}