dylibso/testing-xtp-plugins
An end-to-end example of testing XTP plugins which call host functions + example mocked host functions.
mock
This directory contains the implementation of the mocked host functions. Note that these functions are Extism plugin exports, which become imports to the plugin that calls the host functions.
plugin
This directory contains an example XTP plugin, based on the schema.yaml
schema. It calls the host functions from its export handleLogEvent
and
aggregates the count of events per event source. We test this plugin's behavior
and the host function integration by running it several times with different
inputs to see that the KV data and plugin aggregation of that data is correct.
test
This directory contains the test code that calls into the code in plugin
to
test various aspects of it.
Before compiling the contents, please ensure that you have the following installed:
xtp
(any recent
version)tinygo
(>= 0.31.2)zig
(>= 0.13.0)extism-js
(>= 1.0.0-rc11)npm
(>= 10.2.4)With all of the above installed, you can now run:
make build
After you've built the mock
, plugin
and test
modules, you can run:
make test
or:
cd plugin
xtp plugin test # note: the plugin/xtp.toml [[test]] configuration
File an issue on this repository, or reach out to us on the Extism Discord and we can provide assistance.