Skip to content

Commit

Permalink
remove base_01 template name and add http server test
Browse files Browse the repository at this point in the history
  • Loading branch information
0div committed Dec 16, 2024
1 parent 4437a77 commit fd94afc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
24 changes: 21 additions & 3 deletions packages/js-sdk/tests/sandbox/snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ sandboxTest.skipIf(isDebug)('pause and resume a sandbox with file', async ({ san
assert.equal(readContent2, content)
})

sandboxTest.skipIf(isDebug)('pause and resume a sandbox long running process', async ({ sandbox }) => {
sandboxTest.skipIf(isDebug)('pause and resume a sandbox with long running process', async ({ sandbox }) => {
const filename = 'test_long_running.txt'

sandbox.commands.run(`sleep 2 && echo "done" > /home/user/${filename}`)
sandbox.commands.run(`sleep 2 && echo "done" > /home/user/${filename}`, { background: true })

// the file should not exist before 2 seconds have elapsed
const exists = await sandbox.files.exists(filename)
Expand All @@ -95,4 +95,22 @@ sandboxTest.skipIf(isDebug)('pause and resume a sandbox long running process', a
const readContent2 = await sandbox.files.read(filename)
assert.equal(readContent2.trim(), 'done')
})


sandboxTest.skipIf(isDebug)('pause and resume a sandbox with http server', async ({ sandbox }) => {
await sandbox.commands.run('python3 -m http.server 8000', { background: true })

let url = await sandbox.getHost(8000)
console.log(url)
const response1 = await fetch(`https://${url}`)
assert.equal(response1.status, 200)

await sandbox.pause()
assert.isFalse(await sandbox.isRunning())

await Sandbox.resume(sandbox.sandboxId)
assert.isTrue(await sandbox.isRunning())

url = await sandbox.getHost(8000)
const response2 = await fetch(`https://${url}`)
assert.equal(response2.status, 200)
})
2 changes: 1 addition & 1 deletion packages/js-sdk/tests/setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Sandbox } from '../src'
import { test as base } from 'vitest'

export const template = 'base_01'
export const template = 'base'

interface SandboxFixture {
sandbox: Sandbox
Expand Down
2 changes: 1 addition & 1 deletion packages/python-sdk/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@pytest.fixture()
def template():
return "base_01"
return "base"


@pytest.fixture()
Expand Down

0 comments on commit fd94afc

Please sign in to comment.