Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
yipeng1030 committed Nov 20, 2024
1 parent 5bc54c9 commit f791f0c
Showing 1 changed file with 17 additions and 30 deletions.
47 changes: 17 additions & 30 deletions pkg/util/helm/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,37 +132,24 @@ var _ = Describe("helm util", func() {
Expect(o.Uninstall(cfg)).Should(HaveOccurred()) // release not found
})

It("should fail when release is not one of deployed, failed and superseded", func() {
err := actionCfg.Releases.Create(&release.Release{
Name: o.Name,
Version: 1,
Info: &release.Info{
Status: release.StatusDeployed,
},
Chart: &chart.Chart{},
})
Expect(err).Should(BeNil())
_, err = o.tryUpgrade(actionCfg)
Expect(err).Should(HaveOccurred()) // failed at fetching charts
Expect(o.tryUninstall(actionCfg)).Should(BeNil()) // release exists
})

testCase := []struct {
status release.Status
checkResult bool
}{
{release.StatusDeployed, true},
{release.StatusSuperseded, true},
{release.StatusFailed, true},
{release.StatusUnknown, false},
{release.StatusUninstalled, false},
{release.StatusUninstalling, false},
{release.StatusPendingInstall, false},
{release.StatusPendingUpgrade, false},
{release.StatusPendingRollback, false},
}

It("should fail when status is not one of deployed, failed and superseded.", func() {
testCase := []struct {
status release.Status
checkResult bool
}{
// deployed, failed and superseded
{release.StatusDeployed, true},
{release.StatusSuperseded, true},
{release.StatusFailed, true},
// others
{release.StatusUnknown, false},
{release.StatusUninstalled, false},
{release.StatusUninstalling, false},
{release.StatusPendingInstall, false},
{release.StatusPendingUpgrade, false},
{release.StatusPendingRollback, false},
}

for i := range testCase {
err := actionCfg.Releases.Create(&release.Release{
Name: o.Name,
Expand Down

0 comments on commit f791f0c

Please sign in to comment.