Replies: 1 comment 3 replies
-
Unit tests basically. VRL also provides a test harness for running VRL scripts and asserting on their output. It's all specified here, it's not that much code: https://github.com/vectordotdev/vrl/tree/main/lib/tests To summarize:
Potentially you could "lib-ify" the VRL test harness to accept custom functions and test directories. Note that it was written for internal use.
Examples are a quick way to demonstrate what a function does, it's more related to public docs than actual testing. We run them only to validate that the example is correct, not to verify the function behavior. |
Beta Was this translation helpful? Give feedback.
-
This started as a discussion on Discord with @pront.
I'm writing an application that uses VRL as a crate and I'm adding custom functions. I have to admit it's not easy to know how to write a custom function because there is no documentation about it.
For instance I'm writing:
The questions I still have are:
fn examples
in my RecordId struct and @pront showed me that you run those using./scripts/checks.sh vrl_tests
. I figured that we can test specific functions using something likecargo run --package vrl-tests --bin vrl-tests -- -p functions/set
but this is only in the VRL repo. How would we do it in our own repo that uses VRL with custom functions ?It short I feel there is a lack of documentation around how to use VRL as a crate and how to extend it with a good way to test it.
Beta Was this translation helpful? Give feedback.
All reactions