package contact import "testing" func TestParse_valid(t *testing.T) { sub, errs := Parse("Jimmy", "jim@example.com", "Hello there, this is a test message.") if errs.Any() { t.Fatalf("unexpected errors: %v", errs) } if sub.Name != "Jimmy" || sub.Email != "jim@example.com" { t.Fatalf("got %+v", sub) } } func TestParse_shortMessage(t *testing.T) { _, errs := Parse("Jimmy", "jim@example.com", "short") if !errs.Any() { t.Fatal("expected validation error") } } func TestParse_invalidEmail(t *testing.T) { _, errs := Parse("Jimmy", "not-an-email", "This message is long enough to pass.") if errs["email"] == "" { t.Fatal("expected email error") } }