11import { assert } from 'vitest'
22
3- import Sandbox from '../../src/index.js'
4- import { isDebug , sandboxTest , template , wait } from '../setup.js'
3+ import { isDebug , sandboxTest , wait } from '../setup.js'
54
65sandboxTest . skipIf ( isDebug ) (
76 'ping server in running sandbox' ,
@@ -28,34 +27,35 @@ sandboxTest.skipIf(isDebug)(
2827 }
2928)
3029
31- sandboxTest . skipIf ( isDebug ) ( 'ping server in non-running sandbox' , async ( ) => {
32- const sbx = await Sandbox . create ( template , { timeoutMs : 120_000 } )
33-
34- const cmd = await sbx . commands . run ( 'python -m http.server 8000' , {
35- background : true ,
36- } )
30+ sandboxTest . skipIf ( isDebug ) (
31+ 'ping server in non-running sandbox' ,
32+ async ( { sandbox } ) => {
33+ const cmd = await sandbox . commands . run ( 'python -m http.server 8000' , {
34+ background : true ,
35+ } )
3736
38- try {
39- await wait ( 20_000 )
37+ try {
38+ await wait ( 20_000 )
4039
41- const host = sbx . getHost ( 8000 )
40+ const host = sandbox . getHost ( 8000 )
4241
43- const res = await fetch ( `${ isDebug ? 'http' : 'https' } ://${ host } ` )
42+ const res = await fetch ( `${ isDebug ? 'http' : 'https' } ://${ host } ` )
4443
45- assert . equal ( res . status , 200 )
44+ assert . equal ( res . status , 200 )
4645
47- await sbx . kill ( )
46+ await sandbox . kill ( )
4847
49- const res2 = await fetch ( `${ isDebug ? 'http' : 'https' } ://${ host } ` )
50- assert . equal ( res2 . status , 502 )
48+ const res2 = await fetch ( `${ isDebug ? 'http' : 'https' } ://${ host } ` )
49+ assert . equal ( res2 . status , 502 )
5150
52- const text = await res2 . text ( )
53- assert . equal ( text , 'Sandbox does not exist.' )
54- } finally {
55- try {
56- await cmd . kill ( )
57- } catch ( e ) {
58- console . error ( e )
51+ const text = await res2 . text ( )
52+ assert . equal ( text , 'Sandbox does not exist.' )
53+ } finally {
54+ try {
55+ await cmd . kill ( )
56+ } catch ( e ) {
57+ console . error ( e )
58+ }
5959 }
6060 }
61- } )
61+ )
0 commit comments