@@ -56,6 +56,8 @@ const derivedDeps = {
5656}
5757
5858const app = testApp ( { dotenv : { variables : { VAR_FROM_ENV_FILE : 'env_file_var' } , path : '' } } )
59+ const functionDir = joinPath ( '/tmp' , 'project' , 'extensions' , 'my-function' )
60+ const functionModulePath = joinPath ( functionDir , 'dist' , 'index.wasm' )
5961
6062function createWasmModule ( importModuleName : string ) : Buffer {
6163 const importsModuleNameBytes = Array . from ( importModuleName ) . map ( ( char ) => char . charCodeAt ( 0 ) )
@@ -353,12 +355,10 @@ describe('runWasmOpt', () => {
353355describe ( 'runTrampoline' , ( ) => {
354356 test ( 'does not run trampoline if no relevant imports' , async ( ) => {
355357 // Given
356- const ourFunction = await testFunctionExtension ( )
357- const modulePath = ourFunction . outputPath
358358 vi . mocked ( readFileSync ) . mockReturnValue ( createWasmModule ( 'bar' ) )
359359
360360 // When
361- const got = runTrampoline ( modulePath )
361+ const got = runTrampoline ( functionModulePath )
362362
363363 // Then
364364 await expect ( got ) . resolves . toBeUndefined ( )
@@ -367,13 +367,11 @@ describe('runTrampoline', () => {
367367
368368 test ( 'does not run trampoline if Wasm module is invalid' , async ( ) => {
369369 // Given
370- const ourFunction = await testFunctionExtension ( )
371- const modulePath = ourFunction . outputPath
372370 const invalidWasmModule = Buffer . from ( [ ] )
373371 vi . mocked ( readFileSync ) . mockReturnValue ( invalidWasmModule )
374372
375373 // When
376- const got = runTrampoline ( modulePath )
374+ const got = runTrampoline ( functionModulePath )
377375
378376 // Then
379377 await expect ( got ) . resolves . toBeUndefined ( )
@@ -382,39 +380,35 @@ describe('runTrampoline', () => {
382380
383381 test ( 'runs v1 trampoline on v1 module' , { timeout : 20000 } , async ( ) => {
384382 // Given
385- const ourFunction = await testFunctionExtension ( )
386- const modulePath = ourFunction . outputPath
387383 vi . mocked ( readFileSync ) . mockReturnValue ( createWasmModule ( 'shopify_function_v1' ) )
388384
389385 // When
390- const got = runTrampoline ( modulePath )
386+ const got = runTrampoline ( functionModulePath )
391387
392388 // Then
393389 await expect ( got ) . resolves . toBeUndefined ( )
394390 expect ( exec ) . toHaveBeenCalledWith ( trampolineBinary ( V1_TRAMPOLINE_VERSION ) . path , [
395391 '-i' ,
396- modulePath ,
392+ functionModulePath ,
397393 '-o' ,
398- modulePath ,
394+ functionModulePath ,
399395 ] )
400396 } )
401397
402398 test ( 'runs v2 trampoline on v2 module' , { timeout : 20000 } , async ( ) => {
403399 // Given
404- const ourFunction = await testFunctionExtension ( )
405- const modulePath = ourFunction . outputPath
406400 vi . mocked ( readFileSync ) . mockReturnValue ( createWasmModule ( 'shopify_function_v2' ) )
407401
408402 // When
409- const got = runTrampoline ( modulePath )
403+ const got = runTrampoline ( functionModulePath )
410404
411405 // Then
412406 await expect ( got ) . resolves . toBeUndefined ( )
413407 expect ( exec ) . toHaveBeenCalledWith ( trampolineBinary ( V2_TRAMPOLINE_VERSION ) . path , [
414408 '-i' ,
415- modulePath ,
409+ functionModulePath ,
416410 '-o' ,
417- modulePath ,
411+ functionModulePath ,
418412 ] )
419413 } )
420414} )
0 commit comments