| 1 |
package parse_test |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
|
| 6 |
"git.sr.ht/~rjarry/aerc/lib/parse" |
| 7 |
"github.com/emersion/go-message/mail" |
| 8 |
"github.com/stretchr/testify/assert" |
| 9 |
) |
| 10 |
|
| 11 |
func TestMsgIDList(t *testing.T) { |
| 12 |
tests := []struct { |
| 13 |
name string |
| 14 |
input string |
| 15 |
expected []string |
| 16 |
}{ |
| 17 |
{ |
| 18 |
name: "valid", |
| 19 |
input: "<1q@az> (cmt)\r\n <2w@sx> (khld)", |
| 20 |
expected: []string{"1q@az", "2w@sx"}, |
| 21 |
}, |
| 22 |
{ |
| 23 |
name: "comma", |
| 24 |
input: "<3e@dc>, <4r@fv>,\t<5t@gb>", |
| 25 |
expected: []string{"3e@dc", "4r@fv", "5t@gb"}, |
| 26 |
}, |
| 27 |
{ |
| 28 |
name: "other non-CFWS separators", |
| 29 |
input: "<6y@>, <hn@7u>\n <> <jm@8i>", |
| 30 |
expected: []string{"hn@7u", "jm@8i"}, |
| 31 |
}, |
| 32 |
} |
| 33 |
|
| 34 |
for _, test := range tests { |
| 35 |
var h mail.Header |
| 36 |
h.Set("References", test.input) |
| 37 |
t.Run(test.name, func(t *testing.T) { |
| 38 |
actual := parse.MsgIDList(&h, "References") |
| 39 |
assert.Equal(t, test.expected, actual) |
| 40 |
}) |
| 41 |
} |
| 42 |
} |