Skip to main content

Module testing

Module testing 

Source
Expand description

Testing a plugin without the recorder: feed it messages, look at what it says back.

let dir = testing::temp_dir("my-plugin");
let hello = testing::hello(&dir, serde_json::json!({ "apiKey": "k" }));
let call = testing::call(&dir, "sys1", 101);
let out = testing::run::<MyPlugin>([HostMessage::Hello(hello), HostMessage::CallConcluded(call)]);
assert!(out.ready());
assert_eq!(out.results()[0].1, Outcome::Ok);

Structs§

Captured
What a capture host was sent.
MockServer
A web server on 127.0.0.1 for testing a plugin that talks to one: it answers every request with respond and keeps them for you to look at.
Output
What a plugin said, and how it ended.
Request
A request MockServer got.

Functions§

call
A 3-second call on talkgroup tg of short_name (system 0), with its files written under dir: the JSON, a WAV of silence, and an “M4A” (placeholder bytes, not real audio) in files.m4a.
capture
A Host whose messages are kept, for testing parts of a plugin (like a crate::CallQueue) on their own.
hello
A hello with config and one P25 system, “sys1” (index 0), with no settings of its own — set systems[0].config for those. Calls are under dir, and the plugin’s data folder is dir/data. Calls come as WAV and M4A; for a recorder without an M4A encoder, set audio_formats to ["wav"].
run
Run P on messages (a hello first) as the recorder would, then end its input — so its Plugin::shutdown runs — and collect what it said.
temp_dir
A fresh, empty folder for a test (under the system’s temp folder).