File: header_test.go

package info (click to toggle)
aerc 0.21.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,892 kB
  • sloc: ansic: 1,181; python: 1,000; sh: 553; awk: 360; makefile: 23
file content (42 lines) | stat: -rw-r--r-- 881 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package parse_test

import (
	"testing"

	"git.sr.ht/~rjarry/aerc/lib/parse"
	"github.com/emersion/go-message/mail"
	"github.com/stretchr/testify/assert"
)

func TestMsgIDList(t *testing.T) {
	tests := []struct {
		name     string
		input    string
		expected []string
	}{
		{
			name:     "valid",
			input:    "<1q@az> (cmt)\r\n <2w@sx> (khld)",
			expected: []string{"1q@az", "2w@sx"},
		},
		{
			name:     "comma",
			input:    "<3e@dc>, <4r@fv>,\t<5t@gb>",
			expected: []string{"3e@dc", "4r@fv", "5t@gb"},
		},
		{
			name:     "other non-CFWS separators",
			input:    "<6y@>, <hn@7u>\n <> <jm@8i>",
			expected: []string{"hn@7u", "jm@8i"},
		},
	}

	for _, test := range tests {
		var h mail.Header
		h.Set("References", test.input)
		t.Run(test.name, func(t *testing.T) {
			actual := parse.MsgIDList(&h, "References")
			assert.Equal(t, test.expected, actual)
		})
	}
}