mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +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:
@ -61,6 +61,19 @@ impl PluginTest {
|
||||
&mut self.engine_state
|
||||
}
|
||||
|
||||
/// Make additional command declarations available for use by tests.
|
||||
///
|
||||
/// This can be used to pull in commands from `nu-cmd-lang` for example, as required.
|
||||
pub fn add_decl(
|
||||
&mut self,
|
||||
decl: Box<dyn nu_protocol::engine::Command>,
|
||||
) -> Result<&mut Self, ShellError> {
|
||||
let mut working_set = StateWorkingSet::new(&self.engine_state);
|
||||
working_set.add_decl(decl);
|
||||
self.engine_state.merge_delta(working_set.render())?;
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
/// Evaluate some Nushell source code with the plugin commands in scope with the given input to
|
||||
/// the pipeline.
|
||||
///
|
||||
|
Reference in New Issue
Block a user