File: apply_test.go

package info (click to toggle)
aerc 0.20.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,164 kB
  • sloc: ansic: 1,148; python: 1,000; sh: 553; awk: 330; makefile: 23
file content (53 lines) | stat: -rw-r--r-- 1,220 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
43
44
45
46
47
48
49
50
51
52
53
package patch

import (
	"reflect"
	"testing"
)

func TestPatchApply_ProposeName(t *testing.T) {
	tests := []struct {
		name     string
		exist    []string
		subjects []string
		want     []string
	}{
		{
			name:  "base case",
			exist: nil,
			subjects: []string{
				"[PATCH aerc v3 3/3] notmuch: remove unused code",
				"[PATCH aerc v3 2/3] notmuch: replace notmuch library with internal bindings",
				"[PATCH aerc v3 1/3] notmuch: add notmuch bindings",
			},
			want: []string{"notmuch_v3"},
		},
		{
			name:  "distorted case",
			exist: nil,
			subjects: []string{
				"[PATCH vaerc v3 3/3] notmuch: remove unused code",
				"[PATCH aerc 3v 2/3] notmuch: replace notmuch library with internal bindings",
			},
			want: []string{"notmuch_v1", "notmuch_v3"},
		},
		{
			name:  "invalid patches",
			exist: nil,
			subjects: []string{
				"notmuch: remove unused code",
				": replace notmuch library with internal bindings",
			},
			want: nil,
		},
	}

	for _, test := range tests {
		got := proposePatchName(test.exist, test.subjects)
		if !reflect.DeepEqual(got, test.want) {
			t.Errorf("test '%s' failed to propose the correct "+
				"name: got '%v', but want '%v'", test.name,
				got, test.want)
		}
	}
}