mirror of
https://github.com/nushell/nushell.git
synced 2024-11-29 11:54:02 +01:00
adf38c7c76
# Description I thought about bringing `nu_plugin_msgpack` in, but that is MPL with a clause that prevents other licenses, so rather than adapt that code I decided to take a crack at just doing it straight from `rmp` to `Value` without any `rmpv` in the middle. It seems like it's probably faster, though I can't say for sure how much with the plugin overhead. @IanManske I started on a `Read` implementation for `RawStream` but just specialized to `from msgpack` here, but I'm thinking after release maybe we can polish it up and make it a real one. It works! # User-Facing Changes New commands: - `from msgpack` - `from msgpackz` - `to msgpack` - `to msgpackz` # Tests + Formatting Pretty thorough tests added for the format deserialization, with a roundtrip for serialization. Some example tests too for both `from msgpack` and `to msgpack`. - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting - [ ] update release notes
29 lines
744 B
Rust
29 lines
744 B
Rust
use nu_test_support::nu;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn sample_roundtrip() {
|
|
let path_to_sample_nuon = nu_test_support::fs::fixtures()
|
|
.join("formats")
|
|
.join("msgpack")
|
|
.join("sample.nuon");
|
|
|
|
let sample_nuon =
|
|
std::fs::read_to_string(&path_to_sample_nuon).expect("failed to open sample.nuon");
|
|
|
|
let outcome = nu!(
|
|
collapse_output: false,
|
|
format!(
|
|
"open '{}' | to msgpackz | from msgpackz | to nuon --indent 4",
|
|
path_to_sample_nuon.display()
|
|
)
|
|
);
|
|
|
|
assert!(outcome.status.success());
|
|
assert!(outcome.err.is_empty());
|
|
assert_eq!(
|
|
sample_nuon.replace("\r\n", "\n"),
|
|
outcome.out.replace("\r\n", "\n")
|
|
);
|
|
}
|