Use nu-cmd-lang default context for plugin tests (#12434)

# Description
@ayax79 added `nu-cmd-lang` as a dep for `nu-plugin-test-support` in
order to get access to `let`. Since we have the dep anyway now, we might
as well just add all of the lang commands - there aren't very many of
them and it would be less confusing than only `let` working.

# User-Facing Changes
- Can use some more core nu language features in plugin tests, like
loops and `do`

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting
- [ ] Might need to change something about the plugin testing section of
the book, since I think it says something about there only being the
plugin command itself available
This commit is contained in:
Devyn Cairns
2024-04-06 16:28:08 -07:00
committed by GitHub
parent 01c79bbefc
commit 70520000d2
2 changed files with 15 additions and 3 deletions

View File

@ -73,3 +73,16 @@ fn test_an_example_with_the_wrong_result() -> Result<(), ShellError> {
assert!(result.is_err());
Ok(())
}
#[test]
fn test_requiring_nu_cmd_lang_commands() -> Result<(), ShellError> {
use nu_protocol::Span;
let result = PluginTest::new("hello", HelloPlugin.into())?
.eval("do { let greeting = hello; $greeting }")?
.into_value(Span::test_data());
assert_eq!(Value::test_string("Hello, World!"), result);
Ok(())
}