aboutsummaryrefslogtreecommitdiffstats
path: root/lib/pama/switch_test.go
blob: 04c72dfa7d1b4b38120a27094bdfdf2e8be2332e (plain) (blame)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package pama_test

import (
	"testing"

	"git.sr.ht/~rjarry/aerc/lib/pama"
)

func TestFromSubject(t *testing.T) {
	tests := []struct {
		s    string
		want string
	}{
		{
			s:    "[PATCH aerc] pama: new patch",
			want: "aerc",
		},
		{
			s:    "[PATCH aerc v2] pama: new patch",
			want: "aerc",
		},
		{
			s:    "[PATCH aerc 1/2] pama: new patch",
			want: "aerc",
		},
		{
			s:    "[Patch aerc] pama: new patch",
			want: "aerc",
		},
		{
			s:    "[patch aerc] pama: new patch",
			want: "aerc",
		},
		{
			s:    "[RFC PATCH aerc] pama: new patch",
			want: "aerc",
		},
		{
			s:    "[DRAFT PATCH aerc] pama: new patch",
			want: "aerc",
		},
		{
			s:    "RE: [PATCH aerc v1] pama: new patch",
			want: "aerc",
		},
		{
			s:    "[PATCH] pama: new patch",
			want: "",
		},
		{
			s:    "just a subject line",
			want: "",
		},
		{
			s:    "just a subject line with unrelated [asdf aerc v1]",
			want: "",
		},
	}

	for _, test := range tests {
		got := pama.FromSubject(test.s)
		if got != test.want {
			t.Errorf("failed to get name from '%s': "+
				"got '%s', want '%s'", test.s, got, test.want)
		}
	}
}