Make pipeline metadata available to plugins (#13495)

# Description
Fixes an issue with pipeline metadata not being passed to plugins.
This commit is contained in:
Jack Wright
2024-08-02 11:01:20 -07:00
committed by GitHub
parent ca8eb856e8
commit d081e3386f
10 changed files with 208 additions and 130 deletions

View File

@ -6,7 +6,8 @@ macro_rules! generate_tests {
StreamData,
};
use nu_protocol::{
LabeledError, PluginSignature, Signature, Span, Spanned, SyntaxShape, Value,
DataSource, LabeledError, PipelineMetadata, PluginSignature, Signature, Span, Spanned,
SyntaxShape, Value,
};
#[test]
@ -123,10 +124,15 @@ macro_rules! generate_tests {
)],
};
let metadata = Some(PipelineMetadata {
data_source: DataSource::None,
content_type: Some("foobar".into()),
});
let plugin_call = PluginCall::Run(CallInfo {
name: name.clone(),
call: call.clone(),
input: PipelineDataHeader::Value(input.clone()),
input: PipelineDataHeader::Value(input.clone(), metadata.clone()),
});
let plugin_input = PluginInput::Call(1, plugin_call);
@ -144,7 +150,7 @@ macro_rules! generate_tests {
match returned {
PluginInput::Call(1, PluginCall::Run(call_info)) => {
assert_eq!(name, call_info.name);
assert_eq!(PipelineDataHeader::Value(input), call_info.input);
assert_eq!(PipelineDataHeader::Value(input, metadata), call_info.input);
assert_eq!(call.head, call_info.call.head);
assert_eq!(call.positional.len(), call_info.call.positional.len());
@ -305,7 +311,7 @@ macro_rules! generate_tests {
match returned {
PluginOutput::CallResponse(
4,
PluginCallResponse::PipelineData(PipelineDataHeader::Value(returned_value)),
PluginCallResponse::PipelineData(PipelineDataHeader::Value(returned_value, _)),
) => {
assert_eq!(value, returned_value)
}
@ -325,7 +331,7 @@ macro_rules! generate_tests {
span,
);
let response = PluginCallResponse::PipelineData(PipelineDataHeader::Value(value));
let response = PluginCallResponse::PipelineData(PipelineDataHeader::value(value));
let output = PluginOutput::CallResponse(5, response);
let encoder = $encoder;
@ -341,7 +347,7 @@ macro_rules! generate_tests {
match returned {
PluginOutput::CallResponse(
5,
PluginCallResponse::PipelineData(PipelineDataHeader::Value(returned_value)),
PluginCallResponse::PipelineData(PipelineDataHeader::Value(returned_value, _)),
) => {
assert_eq!(span, returned_value.span());