chore(go): add release note extraction tests
This commit is contained in:
@@ -36,6 +36,19 @@ func TestMainPrintUnreleasedWritesPendingNotes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMainPrintReleaseNotesWritesTaggedSection(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
writeFile(t, filepath.Join(root, "CHANGELOG.md"), "# Changelog\n\n## [Unreleased]\n\n### Added\n\n- Feature.\n\n## [1.1.6] - 2017-12-20\n\n### Fixed\n\n- Historical note.\n")
|
||||
|
||||
stdout, stderr, code := runMain(t, "--print-release-notes", "--version", "1.1.6", "--root", root)
|
||||
if code != 0 {
|
||||
t.Fatalf("expected exit 0, got %d (stderr: %s)", code, stderr)
|
||||
}
|
||||
if stdout != "## [1.1.6] - 2017-12-20\n\n### Fixed\n\n- Historical note.\n" {
|
||||
t.Fatalf("unexpected release notes output: %q", stdout)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMainUsageExitWhenRequiredFlagsMissing(t *testing.T) {
|
||||
_, stderr, code := runMain(t)
|
||||
if code != 2 {
|
||||
|
||||
@@ -128,6 +128,19 @@ func (s *PrepareSuite) TestUnreleasedBody_ReturnsErrorWhenUnreleasedSectionMissi
|
||||
require.ErrorContains(s.T(), err, "unreleased section")
|
||||
}
|
||||
|
||||
func (s *PrepareSuite) TestReleaseNotes_ReturnsReleaseSectionForVersion() {
|
||||
notes, err := vociferate.ReleaseNotes(s.rootDir, "1.1.6", vociferate.Options{})
|
||||
|
||||
require.NoError(s.T(), err)
|
||||
require.Equal(s.T(), "## [1.1.6] - 2017-12-20\n\n### Fixed\n\n- Historical note.\n", notes)
|
||||
}
|
||||
|
||||
func (s *PrepareSuite) TestReleaseNotes_ReturnsErrorWhenVersionSectionMissing() {
|
||||
_, err := vociferate.ReleaseNotes(s.rootDir, "9.9.9", vociferate.Options{})
|
||||
|
||||
require.ErrorContains(s.T(), err, "release notes section")
|
||||
}
|
||||
|
||||
func (s *PrepareSuite) TestRecommendedTag_ReturnsErrorWhenUnreleasedHasOnlyTemplateHeadings() {
|
||||
require.NoError(s.T(), os.WriteFile(
|
||||
filepath.Join(s.rootDir, "CHANGELOG.md"),
|
||||
|
||||
Reference in New Issue
Block a user