1package gitlab
2
3import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7)
8
9func TestGetNewTitle(t *testing.T) {
10 type args struct {
11 diff string
12 }
13 type want struct {
14 title string
15 }
16 tests := []struct {
17 name string
18 args args
19 want want
20 }{
21 {
22 name: "addition diff",
23 args: args{
24 diff: "**first issue** to **first issue{+ edited+}**",
25 },
26 want: want{
27 title: "first issue edited",
28 },
29 },
30 {
31 name: "deletion diff",
32 args: args{
33 diff: "**first issue{- edited-}** to **first issue**",
34 },
35 want: want{
36 title: "first issue",
37 },
38 },
39 {
40 name: "mixed diff",
41 args: args{
42 diff: "**first {-issue-}** to **first {+bug+}**",
43 },
44 want: want{
45 title: "first bug",
46 },
47 },
48 }
49
50 for _, tt := range tests {
51 t.Run(tt.name, func(t *testing.T) {
52 title := getNewTitle(tt.args.diff)
53 assert.Equal(t, tt.want.title, title)
54 })
55 }
56}