forked from extern/nushell
Add an example Nushell plugin written in Nushell itself (#12574)
# Description As suggested by @fdncred. It's neat that this is possible, but the particularly useful part of this is that we can actually test it because it doesn't have any external dependencies, unlike the python plugin. Right now this just implements exactly the same behavior as the python plugin, but we could have it exercise a few more things. Also fixes a couple of bugs: - `.nu` plugins were not run with `nu --stdin`, so they couldn't take input. - `register` couldn't be called if `--no-config-file` was set, because it would error on trying to update the plugin file. # User-Facing Changes - `nu_plugin_nu_example` plugin added. - `register` now works in `--no-config-file` mode. # Tests + Formatting Tests added for `nu_plugin_nu_example`. - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting - [ ] Add the version bump to the release script just like for python
This commit is contained in:
26
tests/plugins/nu_plugin_nu_example.rs
Normal file
26
tests/plugins/nu_plugin_nu_example.rs
Normal file
@ -0,0 +1,26 @@
|
||||
use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn register() {
|
||||
let out = nu!("register crates/nu_plugin_nu_example/nu_plugin_nu_example.nu");
|
||||
assert!(out.status.success());
|
||||
assert!(out.out.trim().is_empty());
|
||||
assert!(out.err.trim().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn call() {
|
||||
let out = nu!(r#"
|
||||
register crates/nu_plugin_nu_example/nu_plugin_nu_example.nu
|
||||
nu_plugin_nu_example 4242 teststring
|
||||
"#);
|
||||
assert!(out.status.success());
|
||||
|
||||
assert!(out.err.contains("name: nu_plugin_nu_example"));
|
||||
assert!(out.err.contains("4242"));
|
||||
assert!(out.err.contains("teststring"));
|
||||
|
||||
assert!(out.out.contains("one"));
|
||||
assert!(out.out.contains("two"));
|
||||
assert!(out.out.contains("three"));
|
||||
}
|
Reference in New Issue
Block a user