Skip to content

Commit

Permalink
tests: Add tutorial test
Browse files Browse the repository at this point in the history
I already broke the tutorial way too often. Add a test case.
  • Loading branch information
holesch committed Aug 16, 2024
1 parent 23b85e5 commit 0d522bf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_tutorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
async def test_tutorial(vms):
async with vms.hub.ssh_task("not-my-board hub", "hub", wait_ready=True):
async with vms.hub.ssh_task(
"python3 -m http.server -d ./src/tests/tutorial -b localhost 8080",
"http_server",
):
async with vms.hub.ssh_task(
"not-my-board export http://localhost:2092 ./src/tests/tutorial/tutorial-tcp-place.toml",
"export",
wait_ready=True,
):
async with vms.hub.ssh_task_root(
"not-my-board agent http://localhost:2092", "agent", wait_ready=True
):
await vms.hub.ssh(
"doas not-my-board attach ./src/tests/tutorial/tutorial-tcp.toml"
)

await vms.hub.ssh_poll("nc -z localhost 8080")
result = await vms.hub.ssh(
"wget -qO - http://localhost:8081/hello", prefix="wget"
)
assert result.stdout.rstrip() == "Hello, World!"
1 change: 1 addition & 0 deletions tests/tutorial/hello
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, World!
5 changes: 5 additions & 0 deletions tests/tutorial/tutorial-tcp-place.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
port = 2192

[[parts]]
compatible = [ "tutorial-http-server" ]
tcp.http = { host = "localhost", port = 8080 }
3 changes: 3 additions & 0 deletions tests/tutorial/tutorial-tcp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[parts.http-server]
compatible = [ "tutorial-http-server" ]
tcp.http = { local_port = 8081 }

0 comments on commit 0d522bf

Please sign in to comment.