Add-ons: testing
For developers
Test an add-on at two levels:
cargo test |
venolio-addon test |
|
|---|---|---|
| Runs | Your Rust functions natively | The WebAssembly build in Venolio’s sandbox |
| Host | venolio_addon::mock::MockHost |
The same stand-in host, fed by fixture files |
| Checks | Logic, host requests, grants, call and storage limits | All of that, plus fuel, memory, the module’s imports and exports, output size and the real entry_point! export |
| Speed | Fastest; use a debugger | Builds the module first (or use --no-build) |
Neither uses the network or a Venolio server. The stand-in host answers like Venolio: the same
validation, messages, denied flags and limits. It does not model teamspaces or the granting
administrator’s own access (a page or database in the fixtures counts as granted, anything else
as outside the grants), it does not check property values against a database’s properties, and
HTTP answers come from fixtures. Before you submit, install the package in a Venolio of your own
and try it on real data.
Native unit tests
#[cfg(test)]
mod tests {
use super::*;
use venolio_addon::{json, manifest::Manifest, mock::MockHost, testing};
#[test]
fn greets_and_counts() {
let manifest = Manifest::from_json(include_str!("../manifest.json")).unwrap();
let mut host = MockHost::for_manifest(&manifest); // grants every requested scope
let run = testing::run(&mut host, json!({"name": "Alex"}), hello);
assert_eq!(run.status, "succeeded");
assert_eq!(run.output["greeted"], json!(1));
assert_eq!(host.storage()["greeted"], json!(1));
}
}
testing::run(&mut host, input, handler)runshandlerthe wayentry_point!does and returns anOutcome { status, output, error, host_calls, denied_calls, logs, requests }. Storage and created records stay inhostfor the next run.- Build a host with
MockHost::for_manifest,MockHost::from_fixtures(fixtures, Some(&manifest))orMockHost::new(). Adjust it withgrant,revoke,add_page,add_database,add_http,add_http_once(an answer used once, before the others: an expired token’s 401, then success) andstorage_mut. - Extension point inputs are the types in
venolio_addon::extension;host.set_source(Source::Automation)(orWebhook,Ui) applies the rules for runs Venolio starts that way, such as no trigger fires from automations. crypto.sign_rs256works in the stand-in host as in Venolio;venolio_addon::testing::test_rsa_key_pem()is a public key for tests only.
The crate needs crate-type = ["cdylib", "rlib"] for cargo test; the starting project has it.
Test cases
venolio-addon test runs every tests/*.json file, or the files you name. A file holds one case
or an array of cases:
{
"name": "sends the pages changed since the last digest",
"entry_point": "digest",
"input": { "limit": 10 },
"fixtures": "fixtures/workspace.json",
"before": [{ "entry_point": "digest", "input": null }],
"expect": {
"status": "succeeded",
"output_includes": { "sent": 2 },
"logs_include": ["sent 2 pages"],
"storage": { "last_digest": "2026-03-02T09:00:00Z" },
"storage_absent": ["draft"],
"requests_include": [{ "op": "http.fetch", "method": "POST" }],
"host_calls": 6,
"denied_calls": 0
}
}
| Field | Meaning |
|---|---|
name |
Shown in the report (default: the file name). |
entry_point |
The entry point id from the manifest. |
input |
A function’s input, or an action’s configured input (default null). |
trigger |
Action: the event that started the automation (default null). |
webhook |
Webhook: the request, {headers, body, received_at}. Venolio’s header rules apply and json is filled in. |
ui |
Panel or block: {event, page_id, teamspace_id, now, config, value} (render, no teamspace, the current time and {} settings by default). |
manual |
true passes input unchanged with the source manual, like an administrator’s run. |
fixtures |
Inline fixtures, or a path relative to the project (default: everything requested granted, no data). |
before |
Runs on the same host first, for state that builds up over runs (same fields as a case). |
expect.status |
Default succeeded. |
expect.output |
The exact output. |
expect.output_includes, requests_include |
Objects compared by the keys you give, recursively. A request matches if any host request of the run includes it. |
expect.error_includes, logs_include |
Text the error, or some log line, contains. For failed runs the SDK’s reason is in the logs. |
expect.html_includes |
Text the html of a panel or block render contains. |
expect.storage, storage_absent |
Keys storage must hold (with these values) or must not hold after the run. |
expect.host_calls, denied_calls |
Exact counts. |
The command prints PASS or FAIL per case with the fuel used, and for failures what did not
match, the output, the error and the logs. It exits with status 1 if any case fails.
Fixtures
{
"grants": { "pages:read": {}, "storage": {}, "network": { "hosts": ["hooks.example.com"] } },
"pages": [
{ "id": "0b6f6f5e-6c1a-4f43-9d0e-6a3c7c1f0a01", "title": "Launch plan", "text": "…",
"parent_id": null, "icon": null, "updated_at": "2026-03-02T09:00:00Z" }
],
"databases": [
{ "id": "7d1c2e3f-0000-4a00-8b00-000000000001", "title": "Follow-ups",
"properties": [{ "id": "status", "name": "Status", "type": "select" }],
"records": [{ "id": "…", "page_id": "…", "title": "First", "properties": { "status": "open" } }],
"writable": true }
],
"storage": { "last_digest": "2026-02-01T00:00:00Z" },
"http": [
{ "method": "POST", "url": "https://hooks.example.com/digest", "status": 200,
"headers": { "content-type": "text/plain" }, "body": "ok" }
]
}
| Field | Meaning |
|---|---|
grants |
The scopes granted, as an administrator saves them. Without it, every scope the manifest asks for is granted with all declared hosts. A scope the manifest does not ask for, or an undeclared host, is an error, as in Venolio. {} grants nothing. |
pages |
Pages inside the pages:read grant. id must be a UUID; text, parent_id, icon and updated_at are optional. |
databases |
Databases inside the records:* grants, with properties, records and writable (whether records:write reaches it; default true). Records the add-on creates get the IDs 00000000-0000-4000-8000-000000000001, …002 and so on. |
storage |
Storage before the run. |
http |
Answers for http.fetch, matched by method (default GET), the exact url and, when given, request_body_includes (text the request body must contain). status defaults to 200. A request without a match fails with No HTTP fixture matches …. Only the response headers Venolio passes on are returned. |
Unknown fields are errors, so a typo does not silently test less.
One-off runs
venolio-addon run digest --fixtures fixtures/workspace.json --input '{"limit": 5}'
prints the run report Venolio would give (status, source, output, error, fuel_used,
duration_ms, host_calls, denied_calls, logs) and the host requests the run made. run
takes the same kind-specific options as the case fields above (see
Command-line reference).
About this part of Venolio: Let Claude, ChatGPT and Codex work in your workspace
Checked against the app on . The same help is built into the Venolio apps and works offline. Something wrong or missing? Tell us.