package lists import "testing" func TestValidateEntries(t *testing.T) { t.Parallel() tests := []struct { name string entries []string wantN int }{ {name: "empty list", entries: nil, wantN: 0}, {name: "valid user", entries: []string{"user@example.com"}, wantN: 0}, {name: "valid star domain", entries: []string{"*@example.com"}, wantN: 0}, {name: "valid suffix glob", entries: []string{"*@*.shop", "*@*.ac.in"}, wantN: 0}, {name: "valid plus addressing", entries: []string{"a.b+c@mail-host.co.uk"}, wantN: 0}, {name: "repair then valid", entries: []string{"*vsa.instalily.ai"}, wantN: 0}, {name: "missing at", entries: []string{"not-an-email"}, wantN: 1}, {name: "bare domain", entries: []string{"example.com"}, wantN: 1}, {name: "spaces", entries: []string{"user @example.com"}, wantN: 1}, {name: "bad domain", entries: []string{"user@-example.com"}, wantN: 1}, {name: "single label domain", entries: []string{"*@localhost"}, wantN: 1}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { t.Parallel() got := ValidateEntries(tt.entries) if len(got) != tt.wantN { t.Fatalf("ValidateEntries() issues=%v want %d", got, tt.wantN) } }) } } func TestValidateEntryReasons(t *testing.T) { t.Parallel() if got := ValidateEntry(""); got == "" { t.Fatal("expected empty reason") } if got := ValidateEntry("lisa@simpsons.com"); got != "" { t.Fatalf("unexpected: %s", got) } }