Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
0div committed Jan 18, 2025
1 parent 7cc525e commit 06ef257
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
6 changes: 1 addition & 5 deletions packages/js-sdk/tests/sandbox/commands/sendStdin.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { assert } from 'vitest'
import { sandboxTest, wait } from '../../setup.js'
import { sandboxTest } from '../../setup.js'

sandboxTest('send stdin to process', async ({ sandbox }) => {
const text = 'Hello, World!'
const cmd = await sandbox.commands.run('cat', { background: true })

await sandbox.commands.sendStdin(cmd.pid, text)


for (let i = 0; i < 5; i++) {
if (cmd.stdout === text) {
break
Expand Down Expand Up @@ -37,8 +36,6 @@ sandboxTest('send special characters to stdin', async ({ sandbox }) => {

await sandbox.commands.sendStdin(cmd.pid, text)

await wait(5_000)

for (let i = 0; i < 5; i++) {
if (cmd.stdout === text) {
break
Expand Down Expand Up @@ -66,6 +63,5 @@ sandboxTest('send multiline string to stdin', async ({ sandbox }) => {

await cmd.kill()


assert.equal(cmd.stdout, text)
})
24 changes: 16 additions & 8 deletions packages/js-sdk/tests/sandbox/host.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@ sandboxTest.skipIf(isDebug)(
})

try {
await wait(10_000)
await wait(1000)

const host = sandbox.getHost(8000)

const res = await fetch(`${isDebug ? 'http' : 'https'}://${host}`)
let res = await fetch(`${isDebug ? 'http' : 'https'}://${host}`)

for (let i = 0; i < 10; i++) {
if (res.status === 200) {
break
}

res = await fetch(`${isDebug ? 'http' : 'https'}://${host}`)
await wait(500)
}

assert.equal(res.status, 200)
} finally {
Expand All @@ -35,17 +44,16 @@ sandboxTest.skipIf(isDebug)(
})

try {
await wait(10_000)
const host = sandbox.getHost(49983)
const url = `${isDebug ? 'http' : 'https'}://${host}/health`

const host = sandbox.getHost(8000)

const res = await fetch(`${isDebug ? 'http' : 'https'}://${host}`)
const res = await fetch(url)

assert.equal(res.status, 200)
assert.equal(res.status, 204)

await sandbox.kill()

const res2 = await fetch(`${isDebug ? 'http' : 'https'}://${host}`)
const res2 = await fetch(url)
assert.equal(res2.status, 502)

const text = await res2.text()
Expand Down

0 comments on commit 06ef257

Please sign in to comment.