test: add comprehensive test suite for logging, request ID, and user management

Signed-off-by: Noooste <83548733+Noooste@users.noreply.github.com>
This commit is contained in:
Noooste
2026-04-19 13:58:29 +02:00
parent c14463fb8e
commit dd275d2e78
15 changed files with 3772 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
package logger
import "testing"
func TestRedactKey(t *testing.T) {
cases := []struct {
name string
in string
want string
}{
{"empty", "", "***"},
{"short", "abc", "***"},
{"just-under-threshold", "abcdefghijk", "***"}, // 11 chars
{"at-threshold", "abcdefghijkl", "abcd…ijkl"}, // 12 chars
{"long", "GK5a9bfcdefghijklzW9q", "GK5a…zW9q"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
if got := RedactKey(tc.in); got != tc.want {
t.Errorf("RedactKey(%q) = %q, want %q", tc.in, got, tc.want)
}
})
}
}
func TestRedactToken_AlwaysStars(t *testing.T) {
for _, in := range []string{"", "abc", "very-long-secret-token-value"} {
if got := RedactToken(in); got != "***" {
t.Errorf("RedactToken(%q) = %q, want ***", in, got)
}
}
}