mirror of
https://github.com/nushell/nushell.git
synced 2025-02-14 01:21:14 +01:00
25 lines
843 B
Rust
25 lines
843 B
Rust
|
use std::sync::Arc;
|
||
|
|
||
|
use nu_plugin_core::interface_test_util::TestCase;
|
||
|
use nu_plugin_protocol::{test_util::test_plugin_custom_value, PluginInput, PluginOutput};
|
||
|
|
||
|
use crate::{PluginCustomValueWithSource, PluginInterfaceManager, PluginSource};
|
||
|
|
||
|
pub trait TestCaseExt {
|
||
|
/// Create a new [`PluginInterfaceManager`] that writes to this test case.
|
||
|
fn plugin(&self, name: &str) -> PluginInterfaceManager;
|
||
|
}
|
||
|
|
||
|
impl TestCaseExt for TestCase<PluginOutput, PluginInput> {
|
||
|
fn plugin(&self, name: &str) -> PluginInterfaceManager {
|
||
|
PluginInterfaceManager::new(PluginSource::new_fake(name).into(), None, self.clone())
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub fn test_plugin_custom_value_with_source() -> PluginCustomValueWithSource {
|
||
|
PluginCustomValueWithSource::new(
|
||
|
test_plugin_custom_value(),
|
||
|
Arc::new(PluginSource::new_fake("test")),
|
||
|
)
|
||
|
}
|