Skip to content

Commit

Permalink
tools/bumper: assert unhandled errors
Browse files Browse the repository at this point in the history
Signed-off-by: Ram Lavi <[email protected]>
  • Loading branch information
RamLavi committed Jan 7, 2025
1 parent 720bc77 commit 8012fd3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
27 changes: 20 additions & 7 deletions tools/bumper/cnao_repo_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var _ = Describe("Testing internal git CNAO Repo", func() {
Expect(err).ToNot(HaveOccurred(), "Should create temp dir for CNAO repo")

repoDir = filepath.Join(tempDir, "testOwner", "testRepo")
os.MkdirAll(repoDir, 0777)
Expect(os.MkdirAll(repoDir, 0777)).To(Succeed())
githubApi = newFakeGithubApi(repoDir)

gitCnaoRepo = newFakeGitCnaoRepo(githubApi, repoDir, &component{}, expectedTagCommitMap)
Expand Down Expand Up @@ -55,7 +55,10 @@ var _ = Describe("Testing internal git CNAO Repo", func() {

DescribeTable("and checking isPrAlreadyOpened function",
func(r isPrAlreadyOpenedParams) {
defer os.RemoveAll(gitCnaoRepo.gitRepo.localDir)
defer func(path string) {
Expect(os.RemoveAll(path)).To(Succeed())
}(gitCnaoRepo.gitRepo.localDir)

gitCnaoRepo.configParams.Url = repoDir
gitCnaoRepo.configParams.Branch = r.branch

Expand Down Expand Up @@ -111,7 +114,9 @@ var _ = Describe("Testing internal git CNAO Repo", func() {
}
DescribeTable("canonicalizeVersion function",
func(v canonicalizeVersionParams) {
defer os.RemoveAll(gitCnaoRepo.gitRepo.localDir)
defer func(path string) {
Expect(os.RemoveAll(path)).To(Succeed())
}(gitCnaoRepo.gitRepo.localDir)

By("Parsing the version string")
formattedVersion, err := canonicalizeVersion(v.version)
Expand Down Expand Up @@ -212,7 +217,9 @@ var _ = Describe("Testing internal git CNAO Repo", func() {
dummyPRTitle := "dummy new PR title"
DescribeTable("isComponentBumpNeeded function",
func(b isComponentBumpNeededParams) {
defer os.RemoveAll(gitCnaoRepo.gitRepo.localDir)
defer func(path string) {
Expect(os.RemoveAll(path)).To(Succeed())
}(gitCnaoRepo.gitRepo.localDir)
gitCnaoRepo.configParams.Url = repoDir

By("Checking if bump is needed")
Expand Down Expand Up @@ -317,7 +324,9 @@ var _ = Describe("Testing internal git CNAO Repo", func() {

DescribeTable("resetInAllowedList function",
func(r resetInAllowedListParams) {
defer os.RemoveAll(gitCnaoRepo.gitRepo.localDir)
defer func(path string) {
Expect(os.RemoveAll(path)).To(Succeed())
}(gitCnaoRepo.gitRepo.localDir)
worktree, err := gitCnaoRepo.gitRepo.repo.Worktree()

By("Modifying files in the Repo")
Expand Down Expand Up @@ -380,7 +389,9 @@ var _ = Describe("Testing internal git CNAO Repo", func() {

DescribeTable("fileInGlobList function",
func(r fileInGlobListParams) {
defer os.RemoveAll(gitCnaoRepo.gitRepo.localDir)
defer func(path string) {
Expect(os.RemoveAll(path)).To(Succeed())
}(gitCnaoRepo.gitRepo.localDir)

By("Running fileInGlobList on given input")
result := fileInGlobList(r.fileName, r.globList)
Expand Down Expand Up @@ -420,7 +431,9 @@ var _ = Describe("Testing internal git CNAO Repo", func() {

DescribeTable("collectModifiedToTreeList function",
func(r collectModifiedToTreeListParams) {
defer os.RemoveAll(gitCnaoRepo.gitRepo.localDir)
defer func(path string) {
Expect(os.RemoveAll(path)).To(Succeed())
}(gitCnaoRepo.gitRepo.localDir)

if len(r.files) != 0 {
By("Modifying files in the Repo")
Expand Down
14 changes: 10 additions & 4 deletions tools/bumper/component_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var _ = Describe("Testing internal git component", func() {
Expect(err).ToNot(HaveOccurred(), "Should create temp dir for component")

repoDir = filepath.Join(tempDir, "testOwner", "testRepo")
os.MkdirAll(repoDir, 0777)
Expect(os.MkdirAll(repoDir, 0777)).To(Succeed())
githubApi = newFakeGithubApi(repoDir)

gitComponent = newFakeGitComponent(githubApi, repoDir, &component{}, expectedTagCommitMap)
Expand All @@ -32,7 +32,9 @@ var _ = Describe("Testing internal git component", func() {
}
DescribeTable("getVirtualTag function",
func(r getVirtualTagParams) {
defer os.RemoveAll(gitComponent.gitRepo.localDir)
defer func(path string) {
Expect(os.RemoveAll(path)).To(Succeed())
}(gitComponent.gitRepo.localDir)

By("Running api to get the current virtual tag")
commitTested := expectedTagCommitMap[r.TagKey]
Expand Down Expand Up @@ -70,7 +72,9 @@ var _ = Describe("Testing internal git component", func() {
}
DescribeTable("getCurrentReleaseTag function",
func(r currentReleaseParams) {
defer os.RemoveAll(gitComponent.gitRepo.localDir)
defer func(path string) {
Expect(os.RemoveAll(path)).To(Succeed())
}(gitComponent.gitRepo.localDir)

// update test params since you cant do it in the Entry context
gitComponent.configParams.Url = repoDir
Expand Down Expand Up @@ -128,7 +132,9 @@ var _ = Describe("Testing internal git component", func() {
}
DescribeTable("getUpdatedReleaseInfo function",
func(r updatedReleaseParams) {
defer os.RemoveAll(gitComponent.gitRepo.localDir)
defer func(path string) {
Expect(os.RemoveAll(path)).To(Succeed())
}(gitComponent.gitRepo.localDir)

// update test params since you cant do it in the Entry context
gitComponent.configParams = r.comp
Expand Down

0 comments on commit 8012fd3

Please sign in to comment.