From 151bf9ea68950403026a891c099b53fbc5a58c09 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 9 Sep 2021 12:58:07 +1000 Subject: [PATCH] Fix unit tests littering working directory --- .gitignore | 1 - client_test.go | 4 ++++ storage/safe-path_test.go | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 873a6b51..485dee64 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -.torrent.bolt.db .idea diff --git a/client_test.go b/client_test.go index a8192eb1..c626ff89 100644 --- a/client_test.go +++ b/client_test.go @@ -35,6 +35,10 @@ func TestClientDefault(t *testing.T) { } func TestClientNilConfig(t *testing.T) { + // The default config will put crap in the working directory. + origDir, _ := os.Getwd() + defer os.Chdir(origDir) + os.Chdir(t.TempDir()) cl, err := NewClient(nil) require.NoError(t, err) cl.Close() diff --git a/storage/safe-path_test.go b/storage/safe-path_test.go index e12d3333..008cf8a7 100644 --- a/storage/safe-path_test.go +++ b/storage/safe-path_test.go @@ -54,7 +54,7 @@ func TestFileOptsSafeFilePathHandling(t *testing.T) { }, } client := NewFileOpts(NewFileClientOpts{ - ClientBaseDir: "somedir", + ClientBaseDir: t.TempDir(), }) defer func() { c.Check(client.Close(), qt.IsNil) }() torImpl, err := client.OpenTorrent(&info, metainfo.Hash{}) -- 2.44.0