Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Commit

Permalink
patch to fix some bugs found
Browse files Browse the repository at this point in the history
  • Loading branch information
everettraven committed Nov 14, 2021
1 parent 0e59763 commit 68ccfa6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 42 deletions.
10 changes: 0 additions & 10 deletions subcommands/uninstall_sc.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,6 @@ func (uc *UninstallCommand) Run() error {
}
}

//Remove the base directory for the pim
err = uc.tools.RemoveDir(pimDir + pim.BaseDir)

if err != nil {
return err
}
Expand Down Expand Up @@ -211,12 +208,5 @@ func (uc *UninstallCommand) Run() error {
}
}

fmt.Println("Removing pim configuration")
err = uc.tools.RemoveFile(pimPath)

if err != nil {
return err
}

return nil
}
9 changes: 0 additions & 9 deletions subcommands/uninstall_sc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,8 @@ func TestUninstallFlow(t *testing.T) {
"ParseBody",
"ImageExists",
"RemoveDir",
"RemoveDir",
"RemoveImage",
"RemoveAlias",
"RemoveFile",
}

//If the call stack doesn't match the test fails
Expand Down Expand Up @@ -260,7 +258,6 @@ func TestUninstallFlow(t *testing.T) {
rmdirs = append(rmdirs, pimDir+vol.Path)
}

rmdirs = append(rmdirs, pimDir+pim.BaseDir)
//Just use the first pim for the test
break
}
Expand Down Expand Up @@ -526,7 +523,6 @@ func TestUninstallErrorAtRemoveAlias(t *testing.T) {
"ParseBody",
"ImageExists",
"RemoveDir",
"RemoveDir",
"RemoveImage",
"RemoveAlias",
}
Expand Down Expand Up @@ -581,7 +577,6 @@ func TestUninstallErrorAtRemoveImage(t *testing.T) {
"ParseBody",
"ImageExists",
"RemoveDir",
"RemoveDir",
"RemoveImage",
}

Expand Down Expand Up @@ -626,9 +621,7 @@ func TestUninstallAliasFalse(t *testing.T) {
"ParseBody",
"ImageExists",
"RemoveDir",
"RemoveDir",
"RemoveImage",
"RemoveFile",
}

//If the call stack doesn't match the test fails
Expand All @@ -655,8 +648,6 @@ func TestUninstallAliasFalse(t *testing.T) {
rmdirs = append(rmdirs, pimDir+vol.Path)
}

rmdirs = append(rmdirs, pimDir+pim.BaseDir)

//Just use the first pim
break
}
Expand Down
21 changes: 2 additions & 19 deletions utils/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (u *Utility) ImageExists(imageID string, cli Client) (bool, error) {

//Loop through all the images and check if a match is found
for _, image := range images {
if strings.Split(image.RepoTags[0], ":")[0] == imageID {
if image.RepoTags[0] == imageID {
return true, nil
}
}
Expand Down Expand Up @@ -190,25 +190,8 @@ func (u *Utility) RemoveImage(image string, cli Client) error {
//Create the context and search for the image in the list of images
ctx := context.Background()

images, err := cli.ImageList(ctx, types.ImageListOptions{})

//Check for errors
if err != nil {
return err
}

//Create a variable to hold the ID of the image we want to remove
var imageID string

//Loop through all the images and check if a match is found
for _, img := range images {
if strings.Split(img.RepoTags[0], ":")[0] == image {
imageID = img.ID
}
}

//Remove the image
_, err = cli.ImageRemove(ctx, imageID, types.ImageRemoveOptions{Force: true})
_, err := cli.ImageRemove(ctx, image, types.ImageRemoveOptions{Force: true})

//Check for errors
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions utils/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestImageExistsDoesExist(t *testing.T) {
dm := NewDockMock()

//Set the image for testing
img := "image"
img := "image:faketag"

//Set the return images array in the Mock Docker Client
dm.ILRet = []types.ImageSummary{
Expand Down Expand Up @@ -545,8 +545,8 @@ func TestRemoveImage(t *testing.T) {
}

//Check and make sure the image passed in is correct
if dm.IRImgID != imgID {
t.Fatalf("RemoveImage: Expected ImageID: %s | Received: %s", imgID, dm.IRImgID)
if dm.IRImgID != img {
t.Fatalf("RemoveImage: Expected ImageID: %s | Received: %s", img, dm.IRImgID)
}

//Check and make sure the image removal options passed in is correct
Expand Down Expand Up @@ -618,7 +618,7 @@ func TestDocker_Integration(t *testing.T) {
}

//make sure the image exists after being pulled
imgExist, err := util.ImageExists(img, cli)
imgExist, err := util.ImageExists(img+":latest", cli)

if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 68ccfa6

Please sign in to comment.