nushell/tests/plugins/config.rs
Devyn Cairns a29efe28f7
Merge stream_example into example plugin and clean up names (#12234)
# 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
2024-03-19 12:36:46 -05:00

57 lines
1.2 KiB
Rust

use nu_test_support::nu_with_plugins;
#[test]
fn closure() {
let actual = nu_with_plugins!(
cwd: "tests",
plugin: ("nu_plugin_example"),
r#"
$env.env_value = "value from env"
$env.config = {
plugins: {
example: {||
$env.env_value
}
}
}
example config
"#
);
assert!(actual.out.contains("value from env"));
}
#[test]
fn none() {
let actual = nu_with_plugins!(
cwd: "tests",
plugin: ("nu_plugin_example"),
"example config"
);
assert!(actual.err.contains("No config sent"));
}
#[test]
fn record() {
let actual = nu_with_plugins!(
cwd: "tests",
plugin: ("nu_plugin_example"),
r#"
$env.config = {
plugins: {
example: {
key1: "value"
key2: "other"
}
}
}
example config
"#
);
assert!(actual.out.contains("value"));
assert!(actual.out.contains("other"));
}