test(*): add unit tests

This commit is contained in:
Nightapes
2019-07-21 15:07:13 +02:00
parent 69db52e5b1
commit 791983faae
12 changed files with 477 additions and 27 deletions

View File

@@ -15,11 +15,17 @@ type Analyzer struct {
Config config.ChangelogConfig
}
//Release types, like major
type Release string
//Scope of the commit, like feat, fix,..
type Scope string
//Rule for commits
type Rule struct {
Tag string
TagString string
Release string
Release Release
Changelog bool
}
@@ -32,7 +38,7 @@ type analyzeCommit interface {
type AnalyzedCommit struct {
Commit gitutil.Commit
ParsedMessage string
Scope string
Scope Scope
ParsedBreakingChangeMessage string
Tag string
TagString string
@@ -62,9 +68,9 @@ func (a *Analyzer) GetRules() []Rule {
}
// Analyze commits and return commits splitted by major,minor,patch
func (a *Analyzer) Analyze(commits []gitutil.Commit) map[string][]AnalyzedCommit {
func (a *Analyzer) Analyze(commits []gitutil.Commit) map[Release][]AnalyzedCommit {
analyzedCommits := make(map[string][]AnalyzedCommit)
analyzedCommits := make(map[Release][]AnalyzedCommit)
analyzedCommits["major"] = make([]AnalyzedCommit, 0)
analyzedCommits["minor"] = make([]AnalyzedCommit, 0)
analyzedCommits["patch"] = make([]AnalyzedCommit, 0)