vector
vector copied to clipboard
Tests on transforms with multiple output events do not check all outputs
A note for the community
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Problem
Vector automatically splits an array passed to .
into multiple events: . = [event1, event2, etc]
will be output as 3 events from a transform.
I was writing a test for such a transform and I was expecting the test to check all events for matching the condition, but the test passed even if only one of the matched the check.
For example, if we have an array [{"itemPrice": 3000}, {"itemPrice": 5000}]
and check assert!(.itemPrice == 5000)
the test will pass.
Full configuration for this test is provided.
Configuration
[transforms.dummyTest]
type = "remap"
inputs = ["dummy_source"]
source = '''
# . = [{"itemPrice": 3000}, {"itemPrice": 5000}]
., err = parse_json(.message)
if ( err != null )
{
log("Error: {{ err }}", level: "error")
abort
}
. = .events
'''
[[tests]]
# General
name = "Dummy test" # required
# Inputs
[[tests.inputs]]
insert_at = "dummyTest" # required
type = "raw" # required
value = '''
{
"events": [{
"itemPrice": 3000
},{
"itemPrice": 5000
}]
}
'''
[[tests.outputs]]
# General
extract_from = "dummyTest" # required
[[tests.outputs.conditions]]
# Conditions
type = "vrl" # optional, default
source = '''
assert!(.itemPrice == 5000)
'''
Version
nightly-2022-08-08-debian
Debug Output
No response
Example Data
No response
Additional Context
No response
References
No response