Skip to content

Commit 21c04d0

Browse files
committed
test(fscache): move cache initialization inside test cases for better isolation
1 parent 97ad9d1 commit 21c04d0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

store/fscache/issue16_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ func Test_Issue16_LongURLFragmentation(t *testing.T) {
3030
t.Attr("GOARCH", runtime.GOARCH)
3131
t.Attr("GOVERSION", runtime.Version())
3232

33-
tempDir := t.TempDir()
34-
cache, err := Open("test-fragmentation", WithBaseDir(tempDir))
35-
testutil.RequireNoError(t, err)
36-
3733
tests := []struct {
3834
name string
3935
urlLen int
@@ -56,6 +52,9 @@ func Test_Issue16_LongURLFragmentation(t *testing.T) {
5652

5753
for _, tt := range tests {
5854
t.Run(tt.name, func(t *testing.T) {
55+
cache, err := Open("test-fragmentation", WithBaseDir(t.TempDir()))
56+
testutil.RequireNoError(t, err)
57+
5958
// Generate URL of specified length
6059
url := "https://example.com/" + strings.Repeat(
6160
"x",
@@ -71,7 +70,7 @@ func Test_Issue16_LongURLFragmentation(t *testing.T) {
7170

7271
// Test round-trip: Set -> Get -> Delete
7372
data := []byte("test data")
74-
err := cache.Set(url, data)
73+
err = cache.Set(url, data)
7574

7675
if tt.expectOK {
7776
testutil.RequireNoError(t, err)

0 commit comments

Comments
 (0)