From f9e22d62304f5c83fb98d2618d93ba715227048e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 28 Dec 2017 08:51:39 +0100 Subject: pkg/email: don't add <> to email when name is empty Just unnecessary clutter. --- pkg/email/parser_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'pkg/email/parser_test.go') diff --git a/pkg/email/parser_test.go b/pkg/email/parser_test.go index 2341fc385..ed4a76f27 100644 --- a/pkg/email/parser_test.go +++ b/pkg/email/parser_test.go @@ -81,6 +81,24 @@ func TestAddRemoveAddrContext(t *testing.T) { } } +func TestAddAddrContextEmptyName(t *testing.T) { + email := "" + email1, err := AddAddrContext(email, "context") + if err != nil { + t.Fatal(err) + } + if want := "foo+context@bar.com"; want != email1 { + t.Fatalf("want: %q, got %q", want, email1) + } + email2, context1, err := RemoveAddrContext(email1) + if email != email2 { + t.Fatalf("want: %q, got %q", email, email2) + } + if context1 != "context" { + t.Fatalf("got context %q", context1) + } +} + func TestCanonicalEmail(t *testing.T) { canonical := "foo@bar.com" emails := []string{ -- cgit mrf-deployment