Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Jan 29, 2024
1 parent 34f49ca commit 95f8c0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/js-sdk/test/listRunningSandboxes.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ test('list running sandboxes', async () => {
sandboxPromises.push(Sandbox.create({
id: 'base',
apiKey: process.env.E2B_API_KEY,
metadata: { n: i.toString() }
metadata: { n: `js${i}` }
}))
}
const sandboxes = await Promise.all(sandboxPromises)

const running = await Sandbox.list()
const running = (await Sandbox.list()).filter(s => s.metadata?.n?.startsWith('js'))
expect(running.length).toEqual(3)
expect(new Set(running.map(s => s.metadata['n']))).toEqual(new Set(['0', '1', '2']))
expect(new Set(running.map(s => s.metadata['n']))).toEqual(new Set(['js0', 'js1', 'js2']))

for (const sandbox of sandboxes) {
await sandbox.close()
Expand Down
11 changes: 8 additions & 3 deletions packages/python-sdk/tests/test_list_sandboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
def test_list_running_sandboxes():
sandboxes = []
for i in range(3):
sandboxes.append(Sandbox(metadata={"n": str(i)}))
sandboxes.append(Sandbox(metadata={"n": f"py{i}"}))

running_sandboxes = Sandbox.list()
running_sandboxes = list(
filter(
lambda s: s.metadata and s.metadata.get("n", "").startswith("py"),
Sandbox.list(),
)
)
assert len(running_sandboxes) == 3
assert set(map(lambda x: x.metadata['n'], running_sandboxes)) == {'0', '1', '2'}
assert set(map(lambda x: x.metadata["n"], running_sandboxes)) == {"py0", "py1", "py2"}

for sandbox in sandboxes:
sandbox.close()

0 comments on commit 95f8c0e

Please sign in to comment.