Skip to content

Commit

Permalink
Merge pull request #1574 from zhijianli88/cleanup-tempfiles
Browse files Browse the repository at this point in the history
Cleanup tempfiles
  • Loading branch information
justincormack authored Dec 30, 2020
2 parents f30214a + 525677b commit 6ff3461
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ func testInitRepoSigningKeys(t *testing.T, rootType string, serverManagesSnapsho
// Temporary directory where test files will be created
tempBaseDir, err := ioutil.TempDir("", "notary-test-")
require.NoError(t, err, "failed to create a temporary directory: %s", err)
defer os.RemoveAll(tempBaseDir)

repo, _, rootPubKeyID := createRepoAndKey(
t, data.ECDSAKey, tempBaseDir, "docker.com/notary", ts.URL)
Expand Down Expand Up @@ -3606,6 +3607,7 @@ func TestRemoveDelegationErrorWritingChanges(t *testing.T) {
func TestClientInvalidURL(t *testing.T) {
tempBaseDir, err := ioutil.TempDir("", "notary-test-")
require.NoError(t, err, "failed to create a temporary directory: %s", err)
defer os.RemoveAll(tempBaseDir)
r, err := NewFileCachedRepository(
tempBaseDir,
"testGun",
Expand Down
6 changes: 3 additions & 3 deletions cmd/notary/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2931,7 +2931,7 @@ func TestExportImportFlow(t *testing.T) {

// now setup new filestore
newTempDir := tempDirWithConfig(t, "{}")
defer os.Remove(newTempDir)
defer os.RemoveAll(newTempDir)

// and new server
newServer := setupServer()
Expand Down Expand Up @@ -2997,10 +2997,10 @@ func TestDelegationKeyImportExport(t *testing.T) {
defer os.RemoveAll(tempDir)

tempExportedDir := tempDirWithConfig(t, "{}")
defer os.RemoveAll(tempDir)
defer os.RemoveAll(tempExportedDir)

tempImportingDir := tempDirWithConfig(t, "{}")
defer os.RemoveAll(tempDir)
defer os.RemoveAll(tempImportingDir)

// Setup key in a file for import
keyFile, err := ioutil.TempFile("", "pemfile")
Expand Down
3 changes: 2 additions & 1 deletion server/storage/sqlite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package storage
import (
"io/ioutil"
"os"
"path/filepath"
"testing"

_ "github.com/mattn/go-sqlite3"
Expand All @@ -17,7 +18,7 @@ func sqlite3Setup(t *testing.T) (*SQLStorage, func()) {
tempBaseDir, err := ioutil.TempDir("", "notary-test-")
require.NoError(t, err)

dbStore := SetupSQLDB(t, "sqlite3", tempBaseDir+"test_db")
dbStore := SetupSQLDB(t, "sqlite3", filepath.Join(tempBaseDir, "test_db"))
var cleanup = func() {
dbStore.DB.Close()
os.RemoveAll(tempBaseDir)
Expand Down

0 comments on commit 6ff3461

Please sign in to comment.