@@ -2,7 +2,6 @@ package pnpvfs_test
22
33import (
44 "archive/zip"
5- "fmt"
65 "os"
76 "strings"
87 "testing"
@@ -16,7 +15,7 @@ import (
1615 "gotest.tools/v3/assert"
1716)
1817
19- func createTestZip (t * testing.T , files map [string ]string ) string {
18+ func createTestZip (t * testing.T , files map [string ]string ) ( string , vfs. FS ) {
2019 t .Helper ()
2120
2221 tmpDir := t .TempDir ()
@@ -36,7 +35,14 @@ func createTestZip(t *testing.T, files map[string]string) string {
3635 assert .NilError (t , err )
3736 }
3837
39- return zipPath
38+ fs := pnpvfs .From (osvfs .FS ())
39+
40+ t .Cleanup (func () {
41+ errClear := fs .ClearCache ()
42+ assert .NilError (t , errClear )
43+ })
44+
45+ return zipPath , fs
4046}
4147
4248func TestPnpVfs_BasicFileOperations (t * testing.T ) {
@@ -85,15 +91,8 @@ func TestPnpVfs_ZipFileDetection(t *testing.T) {
8591 "package.json" : `{"name": "test-project"}` ,
8692 }
8793
88- zipPath := createTestZip (t , zipFiles )
89-
90- underlyingFS := vfstest .FromMap (map [string ]string {
91- zipPath : "zip content placeholder" ,
92- }, true )
94+ zipPath , fs := createTestZip (t , zipFiles )
9395
94- fs := pnpvfs .From (underlyingFS )
95-
96- fmt .Println (zipPath )
9796 assert .Assert (t , fs .FileExists (zipPath ))
9897
9998 zipInternalPath := zipPath + "/src/index.ts"
@@ -137,10 +136,10 @@ func TestPnpVfs_ErrorHandling(t *testing.T) {
137136 zipFiles := map [string ]string {
138137 "src/index.ts" : "export const hello = 'world';" ,
139138 }
140- zipPath := createTestZip (t , zipFiles )
139+ zipPath , zipFS := createTestZip (t , zipFiles )
141140
142141 testutil .AssertPanics (t , func () {
143- _ = fs .WriteFile (zipPath + "/src/index.ts" , "hello, world" , false )
142+ _ = zipFS .WriteFile (zipPath + "/src/index.ts" , "hello, world" , false )
144143 }, "cannot write to zip file" )
145144 })
146145}
@@ -249,8 +248,7 @@ func TestPnpVfs_RealZipIntegration(t *testing.T) {
249248 "tsconfig.json" : `{"compilerOptions": {"target": "es2020"}}` ,
250249 }
251250
252- zipPath := createTestZip (t , zipFiles )
253- fs := pnpvfs .From (osvfs .FS ())
251+ zipPath , fs := createTestZip (t , zipFiles )
254252
255253 assert .Assert (t , fs .FileExists (zipPath ))
256254
0 commit comments