Skip to content

Commit b76f53a

Browse files
timoknappchristophwitzko
authored andcommitted
test: add test for 'prettified_output' config
1 parent 399e0b4 commit b76f53a

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

examples/GENERATED_CHANGELOG copy.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

pkg/generator/changelog_generator_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,34 @@ func TestDefaultGenerator(t *testing.T) {
3535
t.Fail()
3636
}
3737
}
38+
39+
func TestPrettifiedGenerator(t *testing.T) {
40+
changelogConfig := &generator.ChangelogGeneratorConfig{}
41+
changelogConfig.Commits = []*semrel.Commit{
42+
{},
43+
{SHA: "123456789", Type: "feat", Scope: "app", Message: "commit message"},
44+
{SHA: "abcd", Type: "fix", Scope: "", Message: "commit message"},
45+
{SHA: "87654321", Type: "ci", Scope: "", Message: "commit message"},
46+
{SHA: "43218765", Type: "build", Scope: "", Message: "commit message"},
47+
{SHA: "12345678", Type: "yolo", Scope: "swag", Message: "commit message"},
48+
{SHA: "12345678", Type: "chore", Scope: "", Message: "commit message", Raw: []string{"", "BREAKING CHANGE: test"}, Change: &semrel.Change{Major: true}},
49+
{SHA: "12345679", Type: "chore!", Scope: "user", Message: "another commit message", Raw: []string{"another commit message", "changed ID int into UUID"}, Change: &semrel.Change{Major: true}},
50+
{SHA: "stop", Type: "chore", Scope: "", Message: "not included"},
51+
}
52+
changelogConfig.LatestRelease = &semrel.Release{SHA: "stop"}
53+
changelogConfig.NewVersion = "2.0.0"
54+
generator := &DefaultChangelogGenerator{prettifiedOutput: true}
55+
changelog := generator.Generate(changelogConfig)
56+
if !strings.Contains(changelog, "* **app:** commit message (12345678)") ||
57+
!strings.Contains(changelog, "* commit message (abcd)") ||
58+
!strings.Contains(changelog, "#### 🎁 Feature") ||
59+
!strings.Contains(changelog, "#### 🐞 Bug Fixes") ||
60+
!strings.Contains(changelog, "#### 🔁 CI") ||
61+
!strings.Contains(changelog, "#### 📦 Build") ||
62+
!strings.Contains(changelog, "#### 📣 Breaking Changes") ||
63+
!strings.Contains(changelog, "#### yolo") ||
64+
!strings.Contains(changelog, "```\nBREAKING CHANGE: test\n```") ||
65+
strings.Contains(changelog, "not included") {
66+
t.Fail()
67+
}
68+
}

0 commit comments

Comments
 (0)