Testing
Two layers: unit tests (vow test, no network) and e2e smoke (curl against a live server).
Unit tests — run.sh
Section titled “Unit tests — run.sh”./vow-frameworks/vow-web-server/tests/run.shRuns:
| File | Covers |
|---|---|
tests/router.vow |
Methods, params, mount, 405 |
tests/middleware.vow |
Auth halt, path scope, order |
tests/load.vow |
Dispatch load |
tests/static.vow |
MIME + path guard |
Example router test:
test "router method not allowed" { let r = router.router_get(router.router_new(), "/only-get", stub_ok); assert router.router_try_dispatch(r, "POST /only-get") == 405;}try_handle (Supertest-lite)
Section titled “try_handle (Supertest-lite)”app.try_handle(a, raw) returns status only — no socket I/O:
let a = app.get(app.use_mw(app.app(), middleware.kind_auth_header()), "/health", health);assert app.try_handle(a, "GET /health") == 401;assert app.try_handle(a, "GET /other") == 404;Raw request format: "METHOD /path" or "METHOD /path?query=1".
testutil helpers
Section titled “testutil helpers”tests/testutil.vow wraps common assertions:
import tests.testutil
assert testutil.expect_ok(a, "GET /health");assert testutil.expect_unauthorized(a, "GET /api/x");assert testutil.expect_not_found(a, "GET /nope");assert testutil.expect_status(a, "POST /health", 405);Copy or import testutil into your project’s tests for the same ergonomics.
E2e — e2e.sh
Section titled “E2e — e2e.sh”./vow-frameworks/vow-web-server/tests/e2e.shBuilds each demo server, waits for /health, then curl-checks:
| Check | Expected |
|---|---|
GET /health JSON + Content-Type |
200, application/json |
GET /hello |
200, body contains hello |
GET /nope |
404 |
POST /health |
405 |
| OPTIONS preflight (middleware demo) | 204 |
JSON POST /item |
201 or 200 |
Uses tests/e2e.grants.toml for pinned net grants and port 8787.
Additional wire tests:
./vow-frameworks/vow-web-server/tests/http_wire.sh # HTTP/1.1 keep-alivePatterns for your app
Section titled “Patterns for your app”Handler-only tests — build the App, assert statuses:
test "health ok" { let a = app.get(app.app(), "/health", health); assert app.try_handle(a, "GET /health") == 200;}Middleware isolation — register auth/json before routes, verify halt:
test "json body required" { let a = app.post(app.use_json(app.app()), "/item", create_item); // try_handle does not simulate full HTTP bodies; test parse_json in request tests // or use e2e for POST integration.}Packaged project — from vow-examples/vow-web-server/integration_rest/:
vpm install && ./e2e.shBuild + dependency smoke without blocking on listen.