-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_snapshots.py
More file actions
48 lines (38 loc) · 1.25 KB
/
test_snapshots.py
File metadata and controls
48 lines (38 loc) · 1.25 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import asyncio
import pytest
import uuid
from deno_sandbox import AsyncDenoDeploy
from deno_sandbox.api_types_generated import Volume
def gen_volume_name() -> str:
return f"test-volume-{uuid.uuid4().hex[:8]}"
@pytest.mark.asyncio(loop_scope="session")
async def test_volume_create_root_async():
sdk = AsyncDenoDeploy()
slug = gen_volume_name()
volume = await sdk.volumes.create(
{
"capacity": "10GB",
"region": "ord",
"slug": slug,
"from_snapshot": "builtin:debian-13",
}
)
expected: Volume = {
"id": volume["id"],
"slug": slug,
"capacity": 10000000000,
"estimated_allocated_size": 0,
"estimated_flattened_size": 0,
"region": "ord",
"base_snapshot": None,
"is_bootable": True,
}
assert volume == expected
async with sdk.sandbox.create({"root": volume["slug"], "region": "ord"}) as sb:
await sb.fs.write_text_file("/app/foo.txt", "foo")
cp = await sb.spawn("sync")
await cp.wait()
await asyncio.sleep(1)
async with sdk.sandbox.create({"root": volume["slug"], "region": "ord"}) as sb:
content = await sb.fs.read_text_file("/app/foo.txt")
assert content == "foo"