Skip to content

Commit

Permalink
Use testing.T.TempDir() for temporary test directories
Browse files Browse the repository at this point in the history
These test directories are always unique per test and will be cleaned up
automatically after the test ends.
  • Loading branch information
jrick committed Feb 18, 2025
1 parent c4c2371 commit 0466a56
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion wallet/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var basicWalletConfig = Config{
}

func testWallet(ctx context.Context, t *testing.T, cfg *Config, seed []byte) (w *Wallet, teardown func()) {
f, err := os.CreateTemp("", "dcrwallet.testdb")
f, err := os.CreateTemp(t.TempDir(), "dcrwallet.testdb")
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion wallet/udb/txcommon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
)

func tempDB(t *testing.T) (db walletdb.DB, teardown func()) {
f, err := os.CreateTemp("", "udb")
f, err := os.CreateTemp(t.TempDir(), "udb")
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 0466a56

Please sign in to comment.