2024-01-15 09:59:47 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-03-19 18:36:46 +01:00
|
|
|
example config
|
2024-01-15 09:59:47 +01:00
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
assert!(actual.out.contains("value from env"));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn none() {
|
|
|
|
let actual = nu_with_plugins!(
|
|
|
|
cwd: "tests",
|
|
|
|
plugin: ("nu_plugin_example"),
|
2024-03-19 18:36:46 +01:00
|
|
|
"example config"
|
2024-01-15 09:59:47 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-03-19 18:36:46 +01:00
|
|
|
example config
|
2024-01-15 09:59:47 +01:00
|
|
|
"#
|
|
|
|
);
|
|
|
|
|
|
|
|
assert!(actual.out.contains("value"));
|
|
|
|
assert!(actual.out.contains("other"));
|
|
|
|
}
|