Skip to content

Commit

Permalink
Merge pull request #2770 from saschagrunert/test-new-patch
Browse files Browse the repository at this point in the history
Update `TestNewPatchRelease`
  • Loading branch information
k8s-ci-robot committed Nov 23, 2022
2 parents 394cf77 + 91ef952 commit 70f0d6f
Show file tree
Hide file tree
Showing 149 changed files with 45,299 additions and 41,345 deletions.
352 changes: 79 additions & 273 deletions cmd/krel/cmd/changelog_data_test.go

Large diffs are not rendered by default.

23 changes: 12 additions & 11 deletions cmd/krel/cmd/changelog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ import (

func (s *sut) getChangelogOptions(tag string) *changelog.Options {
return &changelog.Options{
RepoPath: s.repo.Dir(),
// Uncomment to record data:
// RecordDir: filepath.Join(testDataDir, "changelog-"+tag),
ReplayDir: filepath.Join(testDataDir, "changelog-"+tag),
RepoPath: s.repo.Dir(),
Tag: tag,
Tars: ".",
Branch: git.DefaultBranch,
Expand All @@ -56,8 +58,8 @@ func TestNewPatchRelease(t *testing.T) {
s := newSUT(t)
defer s.cleanup(t)

releaseBranch := "release-1.16"
co := s.getChangelogOptions("v1.16.3")
releaseBranch := "release-1.25"
co := s.getChangelogOptions("v1.25.3")
co.Branch = releaseBranch
co.Dependencies = true

Expand All @@ -67,14 +69,14 @@ func TestNewPatchRelease(t *testing.T) {

// Then
// Verify local results
fileContains(t, "CHANGELOG-1.16.html", patchReleaseExpectedHTML)
require.Nil(t, os.RemoveAll("CHANGELOG-1.16.html"))
fileContains(t, "CHANGELOG-1.25.html", patchReleaseExpectedHTML)
require.Nil(t, os.RemoveAll("CHANGELOG-1.25.html"))
for _, x := range []struct {
branch string
commitMessage string
}{
{releaseBranch, "Update CHANGELOG/CHANGELOG-1.16.md for v1.16.3"},
{git.DefaultBranch, "Update directory for v1.16.3 release"},
{releaseBranch, "Update CHANGELOG/CHANGELOG-1.25.md for v1.25.3"},
{git.DefaultBranch, "Update directory for v1.25.3 release"},
} {
// Switch to the test branch
require.Nil(t, s.repo.Checkout(x.branch))
Expand All @@ -85,13 +87,12 @@ func TestNewPatchRelease(t *testing.T) {
require.Contains(t, lastCommit, x.commitMessage)

// Verify changelog contents
result, err := os.ReadFile(
filepath.Join(s.repo.Dir(), changelog.RepoChangelogDir, "CHANGELOG-1.16.md"),
)
changelogPath := filepath.Join(s.repo.Dir(), changelog.RepoChangelogDir, "CHANGELOG-1.25.md")
result, err := os.ReadFile(changelogPath)

require.Nil(t, err)
require.Contains(t, string(result), patchReleaseExpectedTOC)
require.Contains(t, string(result), patchReleaseExpectedContent)
require.Contains(t, string(result), patchReleaseDeps)
}
}

Expand Down
41 changes: 0 additions & 41 deletions cmd/krel/cmd/testdata/changelog-v1.16.3/GetCommit-0.json

This file was deleted.

41 changes: 0 additions & 41 deletions cmd/krel/cmd/testdata/changelog-v1.16.3/GetCommit-1.json

This file was deleted.

Loading

0 comments on commit 70f0d6f

Please sign in to comment.