chore(go): add release note extraction tests

This commit is contained in:
Micheal Wilkinson
2026-03-21 14:33:48 +00:00
parent e625d475a5
commit 9dc28e8229
2 changed files with 26 additions and 0 deletions

View File

@@ -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 {