Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
unit-test: delete what ioutil.TempFile creates
Browse files Browse the repository at this point in the history
ioutil.TempFile creates a new temporary file in the directory dir.
It is the caller's responsibility to remove the file
when no longer needed.

Fixes: #2398

Signed-off-by: Penny Zheng <[email protected]>
  • Loading branch information
Pennyzct committed Jan 17, 2020
1 parent 0244d95 commit 7186c01
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions virtcontainers/acrn_arch_base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"
"testing"

Expand Down Expand Up @@ -128,6 +129,7 @@ func TestAcrnArchBaseAppendImage(t *testing.T) {

image, err := ioutil.TempFile("", "img")
assert.NoError(err)
defer os.Remove(image.Name())
err = image.Close()
assert.NoError(err)

Expand Down
2 changes: 2 additions & 0 deletions virtcontainers/qemu_arch_base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"
"testing"

Expand Down Expand Up @@ -287,6 +288,7 @@ func TestQemuArchBaseAppendImage(t *testing.T) {

image, err := ioutil.TempFile("", "img")
assert.NoError(err)
defer os.Remove(image.Name())
err = image.Close()
assert.NoError(err)

Expand Down

0 comments on commit 7186c01

Please sign in to comment.