Browse code

libnetwork: TestBoltdbBackend(): use t.TempDir()

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2023/07/03 01:14:24
Showing 1 changed files
... ...
@@ -2,6 +2,7 @@ package libnetwork
2 2
 
3 3
 import (
4 4
 	"os"
5
+	"path/filepath"
5 6
 	"testing"
6 7
 
7 8
 	"github.com/docker/docker/libnetwork/datastore"
... ...
@@ -11,9 +12,10 @@ import (
11 11
 func TestBoltdbBackend(t *testing.T) {
12 12
 	defer os.Remove(datastore.DefaultScope("").Client.Address)
13 13
 	testLocalBackend(t, "", "", nil)
14
-	defer os.Remove("/tmp/boltdb.db")
15
-	config := &store.Config{Bucket: "testBackend"}
16
-	testLocalBackend(t, "boltdb", "/tmp/boltdb.db", config)
14
+	tmpPath := filepath.Join(t.TempDir(), "boltdb.db")
15
+	testLocalBackend(t, "boltdb", tmpPath, &store.Config{
16
+		Bucket: "testBackend",
17
+	})
17 18
 }
18 19
 
19 20
 func TestNoPersist(t *testing.T) {