Skip to content

Commit

Permalink
edge case cover
Browse files Browse the repository at this point in the history
  • Loading branch information
Sajiyah-Salat committed Aug 1, 2023
1 parent 32d569c commit 6e2a5e2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/e2e/utils/test_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,18 @@ func (t *TestContext) Destroy() {
//nolint:gosec
// if image name is not present or not provided skip execution of docker command
if t.ImageName != "" {
cmd := exec.Command("docker", "rmi", "-f", t.ImageName)
if _, err := t.Run(cmd); err != nil {
warnError(err)
// Remove white space from image name
trimmedImageName := strings.Trim(t.ImageName, "")
// Check trimmedimage name is empty
if len(trimmedImageName) < 0 {

Check failure on line 249 in test/e2e/utils/test_context.go

View workflow job for this annotation

GitHub Actions / golangci-lint

SA4024: builtin function len does not return negative values (staticcheck)
fmt.Println("Image not set, skip cleaning up of docker image")
} else {
cmd := exec.Command("docker", "rmi", "-f", t.ImageName)
if _, err := t.Run(cmd); err != nil {
warnError(err)
}
}

}
if err := os.RemoveAll(t.Dir); err != nil {
warnError(err)
Expand Down

0 comments on commit 6e2a5e2

Please sign in to comment.