chore(go): add unreleased changelog tests

This commit is contained in:
Micheal Wilkinson
2026-03-21 14:25:19 +00:00
parent 64a7b6d86b
commit b7d1760beb
2 changed files with 32 additions and 0 deletions

View File

@@ -23,6 +23,19 @@ func TestMainRecommendPrintsTag(t *testing.T) {
}
}
func TestMainPrintUnreleasedWritesPendingNotes(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### Fixed\n\n- Bugfix.\n\n## [1.1.6] - 2017-12-20\n")
stdout, stderr, code := runMain(t, "--print-unreleased", "--root", root)
if code != 0 {
t.Fatalf("expected exit 0, got %d (stderr: %s)", code, stderr)
}
if stdout != "### Added\n\n- Feature.\n\n### Fixed\n\n- Bugfix.\n" {
t.Fatalf("unexpected unreleased output: %q", stdout)
}
}
func TestMainUsageExitWhenRequiredFlagsMissing(t *testing.T) {
_, stderr, code := runMain(t)
if code != 2 {