0
0
mirror of https://github.com/thegeeklab/git-sv.git synced 2024-11-21 22:10:39 +00:00
git-sv/sv/testutils.go

55 lines
1.1 KiB
Go
Raw Normal View History

2019-11-17 17:43:01 +00:00
package sv
import (
"time"
2021-02-13 18:40:09 +00:00
"github.com/Masterminds/semver/v3"
2019-11-17 17:43:01 +00:00
)
func TestVersion(v string) *semver.Version {
2019-11-17 17:43:01 +00:00
r, _ := semver.NewVersion(v)
2023-10-12 14:18:25 +00:00
return r
2019-11-17 17:43:01 +00:00
}
func TestCommitlog(ctype string, metadata map[string]string, author string) CommitLog {
breaking := false
if _, found := metadata[BreakingChangeMetadataKey]; found {
breaking = true
}
2023-10-12 14:18:25 +00:00
return CommitLog{
Message: CommitMessage{
Type: ctype,
Description: "subject text",
IsBreakingChange: breaking,
Metadata: metadata,
},
AuthorName: author,
2019-11-17 17:43:01 +00:00
}
}
func TestReleaseNote(
2023-10-12 14:18:25 +00:00
version *semver.Version,
tag string,
date time.Time,
sections []ReleaseNoteSection,
authorsNames map[string]struct{},
) ReleaseNote {
2019-11-17 17:43:01 +00:00
return ReleaseNote{
Version: version,
Tag: tag,
Date: date.Truncate(time.Minute),
Sections: sections,
AuthorsNames: authorsNames,
2019-11-17 17:43:01 +00:00
}
}
func TestNewReleaseNoteCommitsSection(name string, types []string, items []CommitLog) ReleaseNoteCommitsSection {
return ReleaseNoteCommitsSection{
2019-11-17 17:43:01 +00:00
Name: name,
Types: types,
2019-11-17 17:43:01 +00:00
Items: items,
}
}