Skip to content

Commit

Permalink
fix: fix test leaking file (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreya authored Nov 27, 2024
1 parent b6eb32d commit ed4baf8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions integration/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ func TestDocker(t *testing.T) {
HostKeyPath: regKeyPath,
Image: integrationtest.UbuntuImage,
TLSPort: strconv.Itoa(registryAddr.Port),
PasswordDir: dir,
Username: "user",
Password: "password",
})

envs := []string{
Expand Down
6 changes: 6 additions & 0 deletions integration/integrationtest/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ func TmpDir(t *testing.T) string {
tmpdir, err := os.MkdirTemp("", strings.ReplaceAll(t.Name(), "/", "_"))
require.NoError(t, err)
t.Logf("using tmpdir %s", tmpdir)
t.Cleanup(func() {
if !t.Failed() {
// Could be useful in case of test failure.
_ = os.RemoveAll(tmpdir)
}
})
return tmpdir
}

Expand Down

0 comments on commit ed4baf8

Please sign in to comment.