mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 06:45:59 +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:
@ -53,6 +53,7 @@ pub fn examples() -> Vec<PluginExample> {
|
||||
example: "'From: test@email.com
|
||||
Subject: Welcome
|
||||
To: someone@somewhere.com
|
||||
|
||||
Test' | from eml"
|
||||
.into(),
|
||||
result: Some(Value::test_record(record! {
|
||||
@ -73,6 +74,7 @@ Test' | from eml"
|
||||
example: "'From: test@email.com
|
||||
Subject: Welcome
|
||||
To: someone@somewhere.com
|
||||
|
||||
Test' | from eml -b 1"
|
||||
.into(),
|
||||
result: Some(Value::test_record(record! {
|
||||
@ -164,3 +166,10 @@ fn from_eml(input: &Value, body_preview: usize, head: Span) -> Result<Value, Lab
|
||||
|
||||
Ok(Value::record(collected.into_iter().collect(), head))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_examples() -> Result<(), nu_protocol::ShellError> {
|
||||
use nu_plugin_test_support::PluginTest;
|
||||
|
||||
PluginTest::new("formats", crate::FromCmds.into())?.test_command_examples(&FromEml)
|
||||
}
|
||||
|
@ -75,8 +75,9 @@ impl SimplePluginCommand for FromIcs {
|
||||
|
||||
pub fn examples() -> Vec<PluginExample> {
|
||||
vec![PluginExample {
|
||||
example: "'BEGIN:VCALENDAR
|
||||
END:VCALENDAR' | from ics"
|
||||
example: "
|
||||
'BEGIN:VCALENDAR
|
||||
END:VCALENDAR' | from ics"
|
||||
.into(),
|
||||
description: "Converts ics formatted string to table".into(),
|
||||
result: Some(Value::test_list(vec![Value::test_record(record! {
|
||||
@ -263,3 +264,10 @@ fn params_to_value(params: Vec<(String, Vec<String>)>, span: Span) -> Value {
|
||||
|
||||
Value::record(row.into_iter().collect(), span)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_examples() -> Result<(), nu_protocol::ShellError> {
|
||||
use nu_plugin_test_support::PluginTest;
|
||||
|
||||
PluginTest::new("formats", crate::FromCmds.into())?.test_command_examples(&FromIcs)
|
||||
}
|
||||
|
@ -89,3 +89,10 @@ b=2' | from ini"
|
||||
})),
|
||||
}]
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_examples() -> Result<(), nu_protocol::ShellError> {
|
||||
use nu_plugin_test_support::PluginTest;
|
||||
|
||||
PluginTest::new("formats", crate::FromCmds.into())?.test_command_examples(&FromIni)
|
||||
}
|
||||
|
@ -153,3 +153,10 @@ fn params_to_value(params: Vec<(String, Vec<String>)>, span: Span) -> Value {
|
||||
|
||||
Value::record(row.into_iter().collect(), span)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_examples() -> Result<(), nu_protocol::ShellError> {
|
||||
use nu_plugin_test_support::PluginTest;
|
||||
|
||||
PluginTest::new("formats", crate::FromCmds.into())?.test_command_examples(&FromVcf)
|
||||
}
|
||||
|
Reference in New Issue
Block a user