Skip to content

Commit

Permalink
update ut
Browse files Browse the repository at this point in the history
  • Loading branch information
yipeng1030 committed Sep 23, 2024
1 parent 48fd68c commit d9b3a54
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions pkg/util/helm/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,26 +153,41 @@ var _ = Describe("helm util", func() {
Expect(errors.Is(err, ErrReleaseNotDeployed)).Should(BeTrue())
Expect(o.tryUninstall(actionCfg)).Should(BeNil()) // release exists
})

It("get helm release status", func() {
err := actionCfg.Releases.Create(&release.Release{
Name: o.Name,
Version: 1,
Info: &release.Info{
Status: release.StatusFailed,
},
Chart: &chart.Chart{},
})
Expect(err).Should(BeNil())
_, _ = GetValues("", cfg)
status, err := GetHelmReleaseStatus(cfg, actionCfg, o.Name)
Expect(status).Should(Equal(release.StatusFailed))
Expect(err).Should(BeNil())
})
})

It("get chart versions", func() {
versions, _ := GetChartVersions(testing.KubeBlocksChartName)
Expect(versions).Should(BeNil())
})

It("get helm release status", func() {
var o *InstallOpts
var cfg *Config
var actionCfg *action.Configuration

o = &InstallOpts{
Name: types.KubeBlocksChartName,
Chart: "kubeblocks-test-chart",
Namespace: "default",
Version: version.DefaultKubeBlocksVersion,
}
cfg = NewFakeConfig("default")
actionCfg, _ = NewActionConfig(cfg)
Expect(actionCfg).ShouldNot(BeNil())

err := actionCfg.Releases.Create(&release.Release{
Name: o.Name,
Version: 1,
Info: &release.Info{
Status: release.StatusFailed,
},
Chart: &chart.Chart{},
})
Expect(err).Should(BeNil())
_, _ = GetValues("", cfg)
status, err := GetHelmReleaseStatus(cfg, actionCfg, o.Name)
Expect(status).Should(Equal(release.StatusFailed))
Expect(err).Should(BeNil())
})

})

0 comments on commit d9b3a54

Please sign in to comment.