Skip to content

Commit

Permalink
Add tests to validation namespace, dryrun flags as well for installer…
Browse files Browse the repository at this point in the history
… and upgrader
  • Loading branch information
buildAI committed Oct 26, 2020
1 parent 4990b52 commit ab9bfe8
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions pkg/helmcli/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,56 @@ import (

type TestSuite struct {
suite.Suite
c Client
version string
c Client
}

func (s *TestSuite) SetupTest() {
s.c = New()
s.version = "0.1.0"
}

func (s *TestSuite) TestNewUpgraderSetsChartOptionsUsingFlagValues() {
t := s.T()
version := "0.1.0"
dryRun := false
install := false
globalFlags := flags.GlobalFlags{
Namespace: "namespace",
}
flg := flags.UpgradeFlags{
Version: s.version,
Install: install,
Version: version,
Install: install,
DryRun: dryRun,
GlobalFlags: globalFlags,
}
u, _ := s.c.NewUpgrader(flg)
newUpgrader, _ := u.(*upgrader)
assert.Equal(t, s.version, newUpgrader.action.Version)
u, err := s.c.NewUpgrader(flg)
newUpgrader, ok := u.(*upgrader)
assert.NoError(t, err)
assert.True(t, ok)
assert.Equal(t, version, newUpgrader.action.Version)
assert.Equal(t, install, newUpgrader.action.Install)
assert.Equal(t, dryRun, newUpgrader.action.DryRun)
assert.Equal(t, globalFlags.Namespace, newUpgrader.action.Namespace)
}

func (s *TestSuite) TestNewInstallerSetsChartOptionsUsingFlagValues() {
t := s.T()
version := "0.1.0"
dryRun := false
globalFlags := flags.GlobalFlags{
Namespace: "namespace",
}
flg := flags.InstallFlags{
Version: version,
DryRun: dryRun,
GlobalFlags: globalFlags,
}
i, err := s.c.NewInstaller(flg)
newInstaller, ok := i.(*installer)
assert.NoError(t, err)
assert.True(t, ok)
assert.Equal(t, version, newInstaller.action.Version)
assert.Equal(t, dryRun, newInstaller.action.DryRun)
assert.Equal(t, globalFlags.Namespace, newInstaller.action.Namespace)
}

func TestHandler(t *testing.T) {
Expand Down

0 comments on commit ab9bfe8

Please sign in to comment.