fix unit tests and improve naming

pull/5987/head
Medya Gh 2019-11-26 20:07:56 -08:00
parent d8d7849d21
commit d7b6e66038
10 changed files with 12 additions and 12 deletions

View File

@ -163,7 +163,7 @@ func DeleteProfiles(profiles []*pkg_config.Profile) []error {
err := deleteProfile(profile)
if err != nil {
mm, loadErr := machine.LoadMachine(profile.Name)
mm, loadErr := machine.Load(profile.Name)
if !profile.IsValid() || (loadErr != nil || !mm.IsValid()) {
invalidProfileDeletionErrs := deleteInvalidProfile(profile)
@ -263,7 +263,7 @@ func deleteInvalidProfile(profile *pkg_config.Profile) []error {
}
}
pathToMachine := machine.MachinePath(profile.Name, localpath.MiniPath())
pathToMachine := machine.Path(profile.Name, localpath.MiniPath())
if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) {
err := os.RemoveAll(pathToMachine)
if err != nil {

View File

@ -117,7 +117,7 @@ func TestDeleteProfile(t *testing.T) {
t.Errorf("Profile folder of profile \"%s\" was not deleted", profile.Name)
}
pathToMachine := machine.MachinePath(profile.Name, localpath.MiniPath())
pathToMachine := machine.Path(profile.Name, localpath.MiniPath())
if _, err := os.Stat(pathToMachine); !os.IsNotExist(err) {
t.Errorf("Profile folder of profile \"%s\" was not deleted", profile.Name)
}

View File

@ -655,7 +655,7 @@ func (k *Bootstrapper) UpdateCluster(cfg config.MachineConfig) error {
return errors.Wrap(err, "generating kubelet service")
}
glog.Infof("kubelet %s config:\n%s", cfg.KubernetesConfig, kubeletCfg)
glog.Infof("kubelet %s config:\n%+v", kubeletCfg, cfg.KubernetesConfig)
stopCmd := exec.Command("/bin/bash", "-c", "pgrep kubelet && sudo systemctl stop kubelet")
// stop kubelet to avoid "Text File Busy" error

View File

@ -60,15 +60,15 @@ func (h *Machine) IsValid() bool {
return true
}
// ListMachines return all valid and invalid machines
// List return all valid and invalid machines
// If a machine is valid or invalid is determined by the cluster.IsValid function
func ListMachines(miniHome ...string) (validMachines []*Machine, inValidMachines []*Machine, err error) {
func List(miniHome ...string) (validMachines []*Machine, inValidMachines []*Machine, err error) {
pDirs, err := machineDirs(miniHome...)
if err != nil {
return nil, nil, err
}
for _, n := range pDirs {
p, err := LoadMachine(n)
p, err := Load(n)
if err != nil {
glog.Infof("%s not valid: %v", n, err)
inValidMachines = append(inValidMachines, p)
@ -83,8 +83,8 @@ func ListMachines(miniHome ...string) (validMachines []*Machine, inValidMachines
return validMachines, inValidMachines, nil
}
// LoadMachine loads a machine or throws an error if the machine could not be loadedG
func LoadMachine(name string) (*Machine, error) {
// Load loads a machine or throws an error if the machine could not be loadedG
func Load(name string) (*Machine, error) {
api, err := NewAPIClient()
if err != nil {
return nil, err
@ -120,8 +120,8 @@ func machineDirs(miniHome ...string) (dirs []string, err error) {
return dirs, err
}
// MachinePath returns the Minikube machine path of a machine
func MachinePath(machine string, miniHome ...string) string {
// Path returns the Minikube machine path of a machine
func Path(machine string, miniHome ...string) string {
miniPath := localpath.MiniPath()
if len(miniHome) > 0 {
miniPath = miniHome[0]

View File

@ -51,7 +51,7 @@ func TestListMachines(t *testing.T) {
files, _ := ioutil.ReadDir(filepath.Join(localpath.MiniPath(), "machines"))
numberOfMachineDirs := len(files)
validMachines, inValidMachines, err := ListMachines()
validMachines, inValidMachines, err := List()
if err != nil {
t.Error(err)