Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fenglixa committed Jun 11, 2019
1 parent 98ade6d commit b3d76cb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
6 changes: 3 additions & 3 deletions cmd/minikube/cmd/config/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ func isAddonAlreadySet(addon *assets.Addon, enable bool) error {
}

if addonStatus && enable {
return fmt.Errorf("addon %s was already enabled", addon.GetAddon())
return fmt.Errorf("addon %s was already enabled", addon.GetAddonName())
} else if !addonStatus && !enable {
return fmt.Errorf("addon %s was already disabled", addon.GetAddon())
return fmt.Errorf("addon %s was already disabled", addon.GetAddonName())
}

return nil
Expand All @@ -159,7 +159,7 @@ func enableOrDisableAddonInternal(addon *assets.Addon, cmd bootstrapper.CommandR
// check addon status before enabling/disabling it
if err := isAddonAlreadySet(addon, enable); err != nil {
console.ErrStyle(console.Conflict, "%v", err)
os.Exit(exit.Unavailable)
os.Exit(0)
}

if enable {
Expand Down
28 changes: 23 additions & 5 deletions cmd/minikube/cmd/config/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,31 @@ func TestSetBool(t *testing.T) {
}

func TestIsAddonAlreadySet(t *testing.T) {
names := []string{"ingress", "heapster"}
for _, name := range names {
addon := assets.Addons[name]
testCases := []struct {
addonName string
expectErr string
}{
{
addonName: "ingress",
expectErr: "addon ingress was already ",
},
{
addonName: "heapster",
expectErr: "addon heapster was already ",
},
}

for _, test := range testCases {
addon := assets.Addons[test.addonName]
addonStatus, _ := addon.IsEnabled()

expectMsg := test.expectErr + "enabled"
if !addonStatus {
expectMsg = test.expectErr + "disabled"
}
err := isAddonAlreadySet(addon, addonStatus)
if err == nil {
t.Fatalf("did not return error for the addon was already set")
if err.Error() != expectMsg {
t.Errorf("Did not get expected error, \n\n expected: %+v \n\n actual: %+v", expectMsg, err)
}
}
}
4 changes: 2 additions & 2 deletions pkg/minikube/assets/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func NewAddon(assets []*BinAsset, enabled bool, addonName string) *Addon {
return a
}

// GetAddon get the addon name
func (a *Addon) GetAddon() string {
// GetAddonName get the addon name
func (a *Addon) GetAddonName() string {
return a.addonName
}

Expand Down

0 comments on commit b3d76cb

Please sign in to comment.