mirror of
https://github.com/nushell/nushell.git
synced 2024-12-27 01:19:25 +01:00
a29efe28f7
# Description As suggested by @WindSoilder, since plugins can now contain both simple commands that produce `Value` and commands that produce `PipelineData` without having to choose one or the other for the whole plugin, this change merges `stream_example` into `example`. # User-Facing Changes All of the example plugins are renamed. # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting - [ ] Check nushell/nushell.github.io for any docs that match the command names changed
56 lines
1.3 KiB
Rust
56 lines
1.3 KiB
Rust
use nu_test_support::nu_with_plugins;
|
|
|
|
#[test]
|
|
fn get_env_by_name() {
|
|
let result = nu_with_plugins!(
|
|
cwd: ".",
|
|
plugin: ("nu_plugin_example"),
|
|
r#"
|
|
$env.FOO = bar
|
|
example env FOO | print
|
|
$env.FOO = baz
|
|
example env FOO | print
|
|
"#
|
|
);
|
|
assert!(result.status.success());
|
|
assert_eq!("barbaz", result.out);
|
|
}
|
|
|
|
#[test]
|
|
fn get_envs() {
|
|
let result = nu_with_plugins!(
|
|
cwd: ".",
|
|
plugin: ("nu_plugin_example"),
|
|
"$env.BAZ = foo; example env | get BAZ"
|
|
);
|
|
assert!(result.status.success());
|
|
assert_eq!("foo", result.out);
|
|
}
|
|
|
|
#[test]
|
|
fn get_current_dir() {
|
|
let cwd = std::env::current_dir()
|
|
.expect("failed to get current dir")
|
|
.join("tests")
|
|
.to_string_lossy()
|
|
.into_owned();
|
|
let result = nu_with_plugins!(
|
|
cwd: ".",
|
|
plugin: ("nu_plugin_example"),
|
|
"cd tests; example env --cwd"
|
|
);
|
|
assert!(result.status.success());
|
|
assert_eq!(cwd, result.out);
|
|
}
|
|
|
|
#[test]
|
|
fn set_env() {
|
|
let result = nu_with_plugins!(
|
|
cwd: ".",
|
|
plugin: ("nu_plugin_example"),
|
|
"example env NUSHELL_OPINION --set=rocks; $env.NUSHELL_OPINION"
|
|
);
|
|
assert!(result.status.success());
|
|
assert_eq!("rocks", result.out);
|
|
}
|