Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

added additional test coverage for getInfo, updated doc

Mishc0efd6f322e8
diff --git a/apps/web/src/app/(docs)/docs/sandbox/page.mdx b/apps/web/src/app/(docs)/docs/sandbox/page.mdx
index f0aea3e8a..c338ae3d2 100644
--- a/apps/web/src/app/(docs)/docs/sandbox/page.mdx
+++ b/apps/web/src/app/(docs)/docs/sandbox/page.mdx
@@ -70,9 +70,16 @@ const sandbox = await Sandbox.create({ timeoutMs: 60_000 })
// Retrieve sandbox information.
const info = await sandbox.getInfo()
-// Retrieve sandbox expiration date.
-const expirationDate = info.endAt
-console.log(expirationDate)
+console.log(info)
+
+// {
+// "sandboxId": "iiny0783cype8gmoawzmx-ce30bc46",
+// "templateId": "rki5dems9wqfm4r03t7g",
+// "name": "base",
+// "metadata": {},
+// "startedAt": "2025-03-24T15:37:58.076Z",
+// "endAt": "2025-03-24T15:42:58.076Z"
+// }
```
```python
@@ -81,9 +88,18 @@ from e2b_code_interpreter import Sandbox
# Create sandbox with and keep it running for 60 seconds.
sandbox = Sandbox(timeout=60)
-# Retrieve sandbox expiration date.
-expiration_date = sandbox.get_info().end_at
-print(expiration_date)
+# Retrieve sandbox information.
+info = sandbox.get_info()
+
+print(info)
+
+# SandboxInfo(sandbox_id='ig6f1yt6idvxkxl562scj-419ff533',
+# template_id='u7nqkmpn3jjf1tvftlsu',
+# name='base',
+# metadata={},
+# started_at=datetime.datetime(2025, 3, 24, 15, 42, 59, 255612, tzinfo=tzutc()),
+# end_at=datetime.datetime(2025, 3, 24, 15, 47, 59, 255612, tzinfo=tzutc())
+# )
```
</CodeGroup>
diff --git a/packages/js-sdk/tests/api/info.test.ts b/packages/js-sdk/tests/api/info.test.ts
new file mode 100644
index 000000000..147dbae8b
--- /dev/null
+++ b/packages/js-sdk/tests/api/info.test.ts
@@ -0,0 +1,9 @@
+import { expect } from 'vitest'
+
+import { sandboxTest, isDebug } from '../setup.js'
+
+sandboxTest.skipIf(isDebug)('get sandbox info', async ({ sandbox }) => {
+ const info = await sandbox.getInfo()
+ expect(info).toBeDefined()
+ expect(info.sandboxId).toBe(sandbox.sandboxId)
+})
diff --git a/packages/python-sdk/tests/async/api_async/test_sbx_info.py b/packages/python-sdk/tests/async/api_async/test_sbx_info.py
new file mode 100644
index 000000000..18868fd7e
--- /dev/null
+++ b/packages/python-sdk/tests/async/api_async/test_sbx_info.py
@@ -0,0 +1,9 @@
+import pytest
+
+from e2b import AsyncSandbox
+
+
+async def test_get_info(async_sandbox: AsyncSandbox):
+ info = await async_sandbox.get_info()
+ assert info.sandbox_id == async_sandbox.sandbox_id
diff --git a/packages/python-sdk/tests/sync/api_sync/test_sbx_info.py b/packages/python-sdk/tests/sync/api_sync/test_sbx_info.py
new file mode 100644
index 000000000..095bfe367
--- /dev/null
+++ b/packages/python-sdk/tests/sync/api_sync/test_sbx_info.py
@@ -0,0 +1,9 @@
+import pytest
+
+from e2b import Sandbox
+
+
+def test_get_info(sandbox: Sandbox):
+ info = sandbox.get_info()
+ assert info.sandbox_id == sandbox.sandbox_id