-
Notifications
You must be signed in to change notification settings - Fork 860
Expand file tree
/
Copy pathtest_background_build.py
More file actions
33 lines (25 loc) · 928 Bytes
/
test_background_build.py
File metadata and controls
33 lines (25 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import uuid
import pytest
from e2b import Template, wait_for_timeout
@pytest.mark.skip_debug()
def test_build_in_background_should_start_build_and_return_info():
"""Test that build_in_background returns immediately without waiting for build to complete."""
template = (
Template()
.from_image("ubuntu:22.04")
.skip_cache()
.run_cmd("sleep 5") # Add a delay to ensure build takes time
.set_start_cmd('echo "Hello"', wait_for_timeout(10_000))
)
name = f"e2b-test:v1-{uuid.uuid4()}"
build_info = Template.build_in_background(
template,
name,
cpu_count=1,
memory_mb=1024,
)
# Should return quickly (within a few seconds), not wait for the full build
assert build_info is not None
# Verify the build is actually running
status = Template.get_build_status(build_info)
assert status.status.value == "building"