@@ -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 ()
@@ -35,8 +34,21 @@ func createTestZip(t *testing.T, files map[string]string) string {
3534		_ , err  =  f .Write ([]byte (content ))
3635		assert .NilError (t , err )
3736	}
37+ 	
38+ 	underlyingFS  :=  vfstest .FromMap (map [string ]string {
39+ 		zipPath : "zip content placeholder" ,
40+ 	}, true )
41+ 
42+ 	fs  :=  pnpvfs .From (underlyingFS )
43+ 
44+ 	t .Cleanup (func () {
45+ 		err  :=  fs .ClearCache ()
46+ 		if  err  !=  nil  {
47+ 			t .Errorf ("Failed to clear PnP cache: %v" , err )
48+ 		}
49+ 	})
3850
39- 	return  zipPath 
51+ 	return  zipPath ,  fs 
4052}
4153
4254func  TestPnpVfs_BasicFileOperations (t  * testing.T ) {
@@ -85,15 +97,8 @@ func TestPnpVfs_ZipFileDetection(t *testing.T) {
8597		"package.json" : `{"name": "test-project"}` ,
8698	}
8799
88- 	zipPath  :=  createTestZip (t , zipFiles )
89- 
90- 	underlyingFS  :=  vfstest .FromMap (map [string ]string {
91- 		zipPath : "zip content placeholder" ,
92- 	}, true )
93- 
94- 	fs  :=  pnpvfs .From (underlyingFS )
95- 
96- 	fmt .Println (zipPath )
100+ 	zipPath , fs  :=  createTestZip (t , zipFiles )
101+ 	
97102	assert .Assert (t , fs .FileExists (zipPath ))
98103
99104	zipInternalPath  :=  zipPath  +  "/src/index.ts" 
@@ -137,10 +142,10 @@ func TestPnpVfs_ErrorHandling(t *testing.T) {
137142		zipFiles  :=  map [string ]string {
138143			"src/index.ts" : "export const hello = 'world';" ,
139144		}
140- 		zipPath  :=  createTestZip (t , zipFiles )
145+ 		zipPath ,  zipFS  :=  createTestZip (t , zipFiles )
141146
142147		testutil .AssertPanics (t , func () {
143- 			_  =  fs .WriteFile (zipPath + "/src/index.ts" , "hello, world" , false )
148+ 			_  =  zipFS .WriteFile (zipPath + "/src/index.ts" , "hello, world" , false )
144149		}, "cannot write to zip file" )
145150	})
146151}
@@ -249,8 +254,7 @@ func TestPnpVfs_RealZipIntegration(t *testing.T) {
249254		"tsconfig.json" :        `{"compilerOptions": {"target": "es2020"}}` ,
250255	}
251256
252- 	zipPath  :=  createTestZip (t , zipFiles )
253- 	fs  :=  pnpvfs .From (osvfs .FS ())
257+ 	zipPath , fs  :=  createTestZip (t , zipFiles )
254258
255259	assert .Assert (t , fs .FileExists (zipPath ))
256260
0 commit comments