mirror of
https://github.com/oneclickvirt/backtrace.git
synced 2026-07-23 11:20:13 +08:00
25 lines
708 B
Go
25 lines
708 B
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestIndentLegacyOutputLeavesOneLeadingCell(t *testing.T) {
|
|
got := indentLegacyOutput("alpha\n beta\n\tgamma\n")
|
|
want := " alpha\n beta\n\tgamma\n"
|
|
if got != want {
|
|
t.Fatalf("indentLegacyOutput() = %q, want %q", got, want)
|
|
}
|
|
}
|
|
|
|
func TestSanitizeErrorTextRedactsRemoteSecretsAndPaths(t *testing.T) {
|
|
input := "load https://private.example/repo/data?token=secret from /private/cache failed: api_key=hidden"
|
|
got := sanitizeErrorText(input)
|
|
for _, forbidden := range []string{"private.example", "secret", "hidden", "/private/cache"} {
|
|
if strings.Contains(got, forbidden) {
|
|
t.Fatalf("sanitizeErrorText() leaked %q in %q", forbidden, got)
|
|
}
|
|
}
|
|
}
|