test: harden changelog link tests for CI env vars
Some checks failed
Push Validation / validate (push) Has been cancelled
Some checks failed
Push Validation / validate (push) Has been cancelled
This commit is contained in:
@@ -21,6 +21,8 @@ func TestPrepareSuite(t *testing.T) {
|
|||||||
|
|
||||||
func (s *PrepareSuite) SetupTest() {
|
func (s *PrepareSuite) SetupTest() {
|
||||||
s.rootDir = s.T().TempDir()
|
s.rootDir = s.T().TempDir()
|
||||||
|
s.T().Setenv("GITHUB_SERVER_URL", "")
|
||||||
|
s.T().Setenv("GITHUB_REPOSITORY", "")
|
||||||
require.NoError(s.T(), os.MkdirAll(filepath.Join(s.rootDir, ".git"), 0o755))
|
require.NoError(s.T(), os.MkdirAll(filepath.Join(s.rootDir, ".git"), 0o755))
|
||||||
require.NoError(s.T(), os.WriteFile(
|
require.NoError(s.T(), os.WriteFile(
|
||||||
filepath.Join(s.rootDir, ".git", "config"),
|
filepath.Join(s.rootDir, ".git", "config"),
|
||||||
@@ -230,3 +232,35 @@ func (s *PrepareSuite) TestRecommendedTag_UsesCustomVersionFileAndPattern() {
|
|||||||
require.NoError(s.T(), err)
|
require.NoError(s.T(), err)
|
||||||
require.Equal(s.T(), "v2.4.0", tag)
|
require.Equal(s.T(), "v2.4.0", tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *PrepareSuite) TestPrepare_UsesGitHrafnXYZEnvironmentForChangelogLinks() {
|
||||||
|
s.T().Setenv("GITHUB_SERVER_URL", "https://git.hrafn.xyz")
|
||||||
|
s.T().Setenv("GITHUB_REPOSITORY", "aether/vociferate")
|
||||||
|
|
||||||
|
err := vociferate.Prepare(s.rootDir, "1.1.7", "2026-03-20", vociferate.Options{})
|
||||||
|
require.NoError(s.T(), err)
|
||||||
|
|
||||||
|
changelogBytes, readErr := os.ReadFile(filepath.Join(s.rootDir, "changelog.md"))
|
||||||
|
require.NoError(s.T(), readErr)
|
||||||
|
changelog := string(changelogBytes)
|
||||||
|
|
||||||
|
require.Contains(s.T(), changelog, "## [Unreleased](https://git.hrafn.xyz/aether/vociferate/src/branch/main)")
|
||||||
|
require.Contains(s.T(), changelog, "## [1.1.7](https://git.hrafn.xyz/aether/vociferate/releases/tag/v1.1.7) - 2026-03-20")
|
||||||
|
require.Contains(s.T(), changelog, "## [1.1.6](https://git.hrafn.xyz/aether/vociferate/releases/tag/v1.1.6) - 2017-12-20")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PrepareSuite) TestPrepare_UsesGitHubEnvironmentForChangelogLinks() {
|
||||||
|
s.T().Setenv("GITHUB_SERVER_URL", "https://github.com")
|
||||||
|
s.T().Setenv("GITHUB_REPOSITORY", "aether/vociferate")
|
||||||
|
|
||||||
|
err := vociferate.Prepare(s.rootDir, "1.1.7", "2026-03-20", vociferate.Options{})
|
||||||
|
require.NoError(s.T(), err)
|
||||||
|
|
||||||
|
changelogBytes, readErr := os.ReadFile(filepath.Join(s.rootDir, "changelog.md"))
|
||||||
|
require.NoError(s.T(), readErr)
|
||||||
|
changelog := string(changelogBytes)
|
||||||
|
|
||||||
|
require.Contains(s.T(), changelog, "## [Unreleased](https://github.com/aether/vociferate/src/branch/main)")
|
||||||
|
require.Contains(s.T(), changelog, "## [1.1.7](https://github.com/aether/vociferate/releases/tag/v1.1.7) - 2026-03-20")
|
||||||
|
require.Contains(s.T(), changelog, "## [1.1.6](https://github.com/aether/vociferate/releases/tag/v1.1.6) - 2017-12-20")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user