mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
Add example tests (nu-plugin-test-support) for plugins in repo (#12281)
# Description Uses the new `nu-plugin-test-support` crate to test the examples of commands provided by plugins in the repo. Also fixed some of the examples to pass. # User-Facing Changes - Examples that are more guaranteed to work # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib`
This commit is contained in:
@ -51,3 +51,9 @@ impl PluginCommand for CollectExternal {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_examples() -> Result<(), nu_protocol::ShellError> {
|
||||
use nu_plugin_test_support::PluginTest;
|
||||
PluginTest::new("example", Example.into())?.test_command_examples(&CollectExternal)
|
||||
}
|
||||
|
@ -45,3 +45,9 @@ impl PluginCommand for ForEach {
|
||||
Ok(PipelineData::Empty)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_examples() -> Result<(), nu_protocol::ShellError> {
|
||||
use nu_plugin_test_support::PluginTest;
|
||||
PluginTest::new("example", Example.into())?.test_command_examples(&ForEach)
|
||||
}
|
||||
|
@ -76,3 +76,12 @@ impl PluginCommand for Generate {
|
||||
.into_pipeline_data(None))
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_examples() -> Result<(), nu_protocol::ShellError> {
|
||||
use nu_cmd_lang::If;
|
||||
use nu_plugin_test_support::PluginTest;
|
||||
PluginTest::new("example", Example.into())?
|
||||
.add_decl(Box::new(If))?
|
||||
.test_command_examples(&Generate)
|
||||
}
|
||||
|
@ -41,3 +41,9 @@ impl SimplePluginCommand for One {
|
||||
Ok(Value::nothing(call.head))
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_examples() -> Result<(), nu_protocol::ShellError> {
|
||||
use nu_plugin_test_support::PluginTest;
|
||||
PluginTest::new("example", Example.into())?.test_command_examples(&One)
|
||||
}
|
||||
|
@ -46,3 +46,9 @@ impl PluginCommand for Seq {
|
||||
Ok(PipelineData::ListStream(list_stream, None))
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_examples() -> Result<(), nu_protocol::ShellError> {
|
||||
use nu_plugin_test_support::PluginTest;
|
||||
PluginTest::new("example", Example.into())?.test_command_examples(&Seq)
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ impl PluginCommand for Sum {
|
||||
(Type::List(Type::Float.into()), Type::Float),
|
||||
])
|
||||
.plugin_examples(vec![PluginExample {
|
||||
example: "seq 1 5 | example sum".into(),
|
||||
example: "example seq 1 5 | example sum".into(),
|
||||
description: "sum values from 1 to 5".into(),
|
||||
result: Some(Value::test_int(15)),
|
||||
}])
|
||||
@ -88,3 +88,9 @@ impl IntOrFloat {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_examples() -> Result<(), nu_protocol::ShellError> {
|
||||
use nu_plugin_test_support::PluginTest;
|
||||
PluginTest::new("example", Example.into())?.test_command_examples(&Sum)
|
||||
}
|
||||
|
Reference in New Issue
Block a user