yaju-is-always-watching-you/internal/detector/detector_test.go
awayatan f47fef177b
Some checks failed
CI / test (push) Failing after 4s
Add yaju-is-always-watching-you: Forgejo goroku-check webhook bot
Watches issue/PR comments and pushes for flagged phrases; warns commenters
via reply and opens a redacted correction PR for flagged file content,
never rewriting history or deleting content directly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-26 22:47:12 +09:00

39 lines
1.1 KiB
Go

package detector
import (
"reflect"
"testing"
)
func TestDetect(t *testing.T) {
d := New([]string{"しょうもな", "たまげたなあ"})
got := d.Detect("いやしょうもな、たまげたなあ")
want := []string{"しょうもな", "たまげたなあ"}
if !reflect.DeepEqual(got, want) {
t.Fatalf("Detect() = %v, want %v", got, want)
}
if got := d.Detect("普通のコメントです"); got != nil {
t.Fatalf("Detect() = %v, want nil", got)
}
}
func TestRedact(t *testing.T) {
d := New([]string{"しょうもな"})
redacted, matched := d.Redact("それはしょうもな案件だ")
if want := "それは○○○○○案件だ"; redacted != want {
t.Fatalf("Redact() text = %q, want %q", redacted, want)
}
if want := []string{"しょうもな"}; !reflect.DeepEqual(matched, want) {
t.Fatalf("Redact() matched = %v, want %v", matched, want)
}
}
func TestNewDeduplicates(t *testing.T) {
d := New([]string{"a", "a", " b ", "", "b"})
if got := d.phrases; !reflect.DeepEqual(got, []string{"a", "b"}) {
t.Fatalf("phrases = %v, want [a b]", got)
}
}