@@ -1293,8 +1293,8 @@ describe('WorkspaceFsService.write', () => {
12931293
12941294 it ( 'overwrites an existing file, reports created=false, and refreshes the etag' , async ( ) => {
12951295 const fs = makeSession ( { 'a.txt' : 'one' } , emptyHandler ) ;
1296- const before = await fs . read ( { path : 'a.txt' } ) ;
1297- const result = await fs . write ( { path : 'a.txt' , content : 'two' } ) ;
1296+ const before = await fs . read ( { path : 'a.txt' , offset : 0 , length : 1024 , encoding : 'utf-8' } ) ;
1297+ const result = await fs . write ( { path : 'a.txt' , content : 'two' , encoding : 'utf-8' } ) ;
12981298 expect ( result . created ) . toBe ( false ) ;
12991299 expect ( result . etag ) . not . toBe ( before . etag ) ;
13001300 const back = await fs . read ( { path : 'a.txt' , offset : 0 , length : 1024 , encoding : 'utf-8' } ) ;
@@ -1303,15 +1303,15 @@ describe('WorkspaceFsService.write', () => {
13031303
13041304 it ( 'succeeds when base_etag matches the current file' , async ( ) => {
13051305 const fs = makeSession ( { 'a.txt' : 'one' } , emptyHandler ) ;
1306- const before = await fs . read ( { path : 'a.txt' } ) ;
1307- const result = await fs . write ( { path : 'a.txt' , content : 'two' , base_etag : before . etag } ) ;
1306+ const before = await fs . read ( { path : 'a.txt' , offset : 0 , length : 1024 , encoding : 'utf-8' } ) ;
1307+ const result = await fs . write ( { path : 'a.txt' , content : 'two' , base_etag : before . etag , encoding : 'utf-8' } ) ;
13081308 expect ( result . created ) . toBe ( false ) ;
13091309 } ) ;
13101310
13111311 it ( 'throws fs.conflict when base_etag is stale' , async ( ) => {
13121312 const fs = makeSession ( { 'a.txt' : 'one' } , emptyHandler ) ;
1313- await fs . write ( { path : 'a.txt' , content : 'changed by someone else' } ) ;
1314- await expect ( fs . write ( { path : 'a.txt' , content : 'stale write' , base_etag : 'bogus-etag' } ) )
1313+ await fs . write ( { path : 'a.txt' , content : 'changed by someone else' , encoding : 'utf-8' } ) ;
1314+ await expect ( fs . write ( { path : 'a.txt' , content : 'stale write' , base_etag : 'bogus-etag' , encoding : 'utf-8' } ) )
13151315 . rejects . toMatchObject ( { code : 'fs.conflict' } ) ;
13161316 } ) ;
13171317
@@ -1326,32 +1326,32 @@ describe('WorkspaceFsService.write', () => {
13261326
13271327 it ( 'throws fs.is_directory when the target is a directory' , async ( ) => {
13281328 const fs = makeSession ( { 'src/a.ts' : '' } , emptyHandler ) ;
1329- await expect ( fs . write ( { path : 'src' , content : 'x' } ) ) . rejects . toMatchObject ( {
1329+ await expect ( fs . write ( { path : 'src' , content : 'x' , encoding : 'utf-8' } ) ) . rejects . toMatchObject ( {
13301330 code : 'fs.is_directory' ,
13311331 } ) ;
13321332 } ) ;
13331333
13341334 it ( 'throws fs.too_large when the payload exceeds the write cap' , async ( ) => {
13351335 const fs = makeSession ( { } , emptyHandler ) ;
13361336 const big = Buffer . alloc ( 10 * 1024 * 1024 + 1 , 97 ) . toString ( 'utf-8' ) ;
1337- await expect ( fs . write ( { path : 'big.txt' , content : big } ) ) . rejects . toMatchObject ( {
1337+ await expect ( fs . write ( { path : 'big.txt' , content : big , encoding : 'utf-8' } ) ) . rejects . toMatchObject ( {
13381338 code : 'fs.too_large' ,
13391339 } ) ;
13401340 } ) ;
13411341
13421342 it ( 'throws fs.path_escapes for paths leaving the workspace' , async ( ) => {
13431343 const fs = makeSession ( { } , emptyHandler ) ;
1344- await expect ( fs . write ( { path : '../outside.txt' , content : 'x' } ) ) . rejects . toMatchObject ( {
1344+ await expect ( fs . write ( { path : '../outside.txt' , content : 'x' , encoding : 'utf-8' } ) ) . rejects . toMatchObject ( {
13451345 code : 'fs.path_escapes' ,
13461346 } ) ;
1347- await expect ( fs . write ( { path : '/etc/hosts' , content : 'x' } ) ) . rejects . toMatchObject ( {
1347+ await expect ( fs . write ( { path : '/etc/hosts' , content : 'x' , encoding : 'utf-8' } ) ) . rejects . toMatchObject ( {
13481348 code : 'fs.path_escapes' ,
13491349 } ) ;
13501350 } ) ;
13511351
13521352 it ( 'throws fs.path_not_found when the parent directory does not exist' , async ( ) => {
13531353 const fs = makeSession ( { } , emptyHandler ) ;
1354- await expect ( fs . write ( { path : 'missing/dir/f.txt' , content : 'x' } ) ) . rejects . toMatchObject ( {
1354+ await expect ( fs . write ( { path : 'missing/dir/f.txt' , content : 'x' , encoding : 'utf-8' } ) ) . rejects . toMatchObject ( {
13551355 code : 'fs.path_not_found' ,
13561356 } ) ;
13571357 } ) ;
0 commit comments