Files
greeneclipse 8580c996c3 Initial commit of Descrybe v2 without local scratch artifacts.
Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
2026-08-09 22:47:43 +02:00

39 lines
867 B
Go

package email
import (
"encoding/json"
"strings"
"testing"
)
func TestUnsubscribeInfoOmitsTenantPII(t *testing.T) {
t.Parallel()
info := UnsubscribeInfo{
OK: true,
AlreadyDone: true,
Message: "already unsubscribed",
}
b, err := json.Marshal(info)
if err != nil {
t.Fatal(err)
}
raw := string(b)
for _, leak := range []string{"company_id", "email"} {
if strings.Contains(raw, leak) {
t.Fatalf("public unsubscribe JSON must not include %q: %s", leak, raw)
}
}
}
func TestClampUnsubscribeReason(t *testing.T) {
t.Parallel()
long := strings.Repeat("a", maxUnsubscribeReasonLen+50)
got := clampUnsubscribeReason(long)
if len(got) != maxUnsubscribeReasonLen {
t.Fatalf("len=%d want %d", len(got), maxUnsubscribeReasonLen)
}
if got := clampUnsubscribeReason(" ok "); got != "ok" {
t.Fatalf("trim failed: %q", got)
}
}