Comment on page
Testing your code
Triggers can be tested as you develop them by using the
runreveal trigger testcommand.
This command requires the argument
-fwhich will specify the code that you want to test, along with the source code is the data you'd like transform.
When running the test command, the result of a trigger is a boolean
falseindicating whether or not the trigger would invoke any notifications or not, along with an error if one was returned from the python wasm runtime environment. This is a simple example that always will return true.
$ runreveal triggers test --file good-trigger.py --data data.json
$ cat good-trigger.py
If a python error exists while running your transform, the results of that error can be pretty printed using the
jqcommand. Piping the output of the command to
jq -r .Errorwill pretty print the results of Error including all python formatting.
In this case,
falseshould be capitalized as
Falsewhich is the way that python expects booleans to be represented.
$ ./dist/runreveal/runreveal transform test --file bad-transform.py --data data.json | jq -r .Error
Traceback (most recent call last):
File "/transform.py", line 75, in main
resp = v.transform(evt)
File "/test-transform.py", line 2, in transform
NameError: name 'false' is not defined
:) cat bad-transform.py