diff --git a/src/config/unit_test/mod.rs b/src/config/unit_test/mod.rs index 78148b356825e..f5402af37f9cb 100644 --- a/src/config/unit_test/mod.rs +++ b/src/config/unit_test/mod.rs @@ -32,7 +32,7 @@ use crate::{ self, loading, ComponentKey, Config, ConfigBuilder, ConfigPath, SinkOuter, SourceOuter, TestDefinition, TestInput, TestInputValue, TestOutput, }, - event::{Event, LogEvent, Value}, + event::{Event, EventMetadata, LogEvent, Value}, signal, topology::{builder::TopologyPieces, RunningTopology}, }; @@ -581,7 +581,12 @@ fn build_input_event(input: &TestInput) -> Result { result .program .resolve(&mut ctx) - .map(|v| Event::Log(LogEvent::from(v.clone()))) + .map(|_| { + Event::Log(LogEvent::from_parts( + target.value.clone(), + EventMetadata::default_with_value(target.metadata.clone()), + )) + }) .map_err(|e| e.to_string()) } else { Err("input type 'vrl' requires the field 'source'".to_string()) diff --git a/tests/behavior/transforms/vrl_test_input.toml b/tests/behavior/transforms/vrl_test_input.toml index fab976d8029ed..66cc0a8551fc6 100644 --- a/tests/behavior/transforms/vrl_test_input.toml +++ b/tests/behavior/transforms/vrl_test_input.toml @@ -17,3 +17,32 @@ [[tests.outputs.conditions]] type = "vrl" source = """.a.b == "c" && is_timestamp(.d)""" + +##------------------------------------------------------------------------------ + +[transforms.remap_metadata] + inputs = [] + type = "remap" + source = ''' + .event = . + .metadata = % + ''' + +[[tests]] + name = "remap_metadata" + [[tests.inputs]] + insert_at = "remap_metadata" + type = "vrl" + source = ''' + . = "Event" + % = "Metadata" + ''' + + [[tests.outputs]] + extract_from = "remap_metadata" + [[tests.outputs.conditions]] + type = "vrl" + source = ''' + assert_eq!(.event, "Event") + assert_eq!(.metadata, "Metadata") + '''