From 65c72f3e0b0a2095625f6f7b278645bec7173199 Mon Sep 17 00:00:00 2001
From: Alejandro Lopez <a.lopez@yadro.com>
Date: Thu, 3 Aug 2023 10:00:49 +0300
Subject: [PATCH] [#559] Remove manual path handling in fstree tests

Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
---
 .../blobstor/fstree/generic_test.go           | 27 ++++++-------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/pkg/local_object_storage/blobstor/fstree/generic_test.go b/pkg/local_object_storage/blobstor/fstree/generic_test.go
index 49f487d35..757482c78 100644
--- a/pkg/local_object_storage/blobstor/fstree/generic_test.go
+++ b/pkg/local_object_storage/blobstor/fstree/generic_test.go
@@ -1,9 +1,6 @@
 package fstree
 
 import (
-	"os"
-	"path/filepath"
-	"strconv"
 	"testing"
 
 	"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
@@ -11,39 +8,31 @@ import (
 )
 
 func TestGeneric(t *testing.T) {
-	defer func() { _ = os.RemoveAll(t.Name()) }()
-
-	helper := func(t *testing.T, dir string) common.Storage {
+	newTreeFromPath := func(path string) common.Storage {
 		return New(
-			WithPath(dir),
+			WithPath(path),
 			WithDepth(2),
 			WithDirNameLen(2))
 	}
 
-	var n int
 	newTree := func(t *testing.T) common.Storage {
-		dir := filepath.Join(t.Name(), strconv.Itoa(n))
-		return helper(t, dir)
+		return newTreeFromPath(t.TempDir())
 	}
 
 	blobstortest.TestAll(t, newTree, 2048, 16*1024)
 
 	t.Run("info", func(t *testing.T) {
-		dir := filepath.Join(t.Name(), "info")
-		blobstortest.TestInfo(t, func(t *testing.T) common.Storage {
-			return helper(t, dir)
-		}, Type, dir)
+		path := t.TempDir()
+		blobstortest.TestInfo(t, func(*testing.T) common.Storage {
+			return newTreeFromPath(path)
+		}, Type, path)
 	})
 }
 
 func TestControl(t *testing.T) {
-	defer func() { _ = os.RemoveAll(t.Name()) }()
-
-	var n int
 	newTree := func(t *testing.T) common.Storage {
-		dir := filepath.Join(t.Name(), strconv.Itoa(n))
 		return New(
-			WithPath(dir),
+			WithPath(t.TempDir()),
 			WithDepth(2),
 			WithDirNameLen(2))
 	}
-- 
2.45.2