0
0
mirror of https://github.com/thegeeklab/git-sv.git synced 2024-11-25 17:30:40 +00:00
git-sv/sv/releasenotes_test.go

46 lines
1.5 KiB
Go
Raw Normal View History

2019-11-17 17:43:01 +00:00
package sv
import (
"reflect"
"testing"
"time"
2019-11-17 17:43:01 +00:00
)
func TestReleaseNoteProcessorImpl_Get(t *testing.T) {
date := time.Now()
2019-11-17 17:43:01 +00:00
tests := []struct {
name string
date time.Time
2019-11-17 17:43:01 +00:00
commits []GitCommitLog
want ReleaseNote
}{
{
name: "mapped tag",
date: date,
2019-11-17 17:43:01 +00:00
commits: []GitCommitLog{commitlog("t1", map[string]string{})},
want: releaseNote(date, map[string]ReleaseNoteSection{"t1": rnSection("Tag 1", []GitCommitLog{commitlog("t1", map[string]string{})})}, nil),
2019-11-17 17:43:01 +00:00
},
{
name: "unmapped tag",
date: date,
2019-11-17 17:43:01 +00:00
commits: []GitCommitLog{commitlog("t1", map[string]string{}), commitlog("unmapped", map[string]string{})},
want: releaseNote(date, map[string]ReleaseNoteSection{"t1": rnSection("Tag 1", []GitCommitLog{commitlog("t1", map[string]string{})})}, nil),
2019-11-17 17:43:01 +00:00
},
{
name: "breaking changes tag",
date: date,
2019-11-17 17:43:01 +00:00
commits: []GitCommitLog{commitlog("t1", map[string]string{}), commitlog("unmapped", map[string]string{"breakingchange": "breaks"})},
want: releaseNote(date, map[string]ReleaseNoteSection{"t1": rnSection("Tag 1", []GitCommitLog{commitlog("t1", map[string]string{})})}, []string{"breaks"}),
2019-11-17 17:43:01 +00:00
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := NewReleaseNoteProcessor(map[string]string{"t1": "Tag 1", "t2": "Tag 2"})
if got := p.Get(tt.date, tt.commits); !reflect.DeepEqual(got, tt.want) {
2019-11-17 17:43:01 +00:00
t.Errorf("ReleaseNoteProcessorImpl.Get() = %v, want %v", got, tt.want)
}
})
}
}