mirror of
https://github.com/nushell/nushell
synced 2024-12-30 15:03:25 +00:00
5afbfb5c2c
# Description This PR is just a minor development improvement. While working on another feature, I noticed that the root crate lists the super useful `pretty_assertions` in the root crate but doesn't use it in most tests. With this change `pretty_assertions::assert_eq!` is used instead of `core::assert_eq!` for better diffs when debugging the tests. I thought of adding the dependency to other crates but I decided not to since I didn't want a huge disruptive PR :)
56 lines
1.5 KiB
Rust
56 lines
1.5 KiB
Rust
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
|
use nu_test_support::nu_with_plugins;
|
|
use nu_test_support::playground::Playground;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
const TEST_CWD: &str = "tests/fixtures/formats";
|
|
|
|
#[test]
|
|
fn parses_ini() {
|
|
let actual = nu_with_plugins!(
|
|
cwd: TEST_CWD,
|
|
plugin: ("nu_plugin_formats"),
|
|
"open sample.ini | get SectionOne.integer"
|
|
);
|
|
|
|
assert_eq!(actual.out, "1234")
|
|
}
|
|
|
|
#[test]
|
|
fn parses_utf16_ini() {
|
|
let actual = nu_with_plugins!(
|
|
cwd: TEST_CWD,
|
|
plugin: ("nu_plugin_formats"),
|
|
"open ./utf16.ini --raw | decode utf-16 | from ini | rename info | get info | get IconIndex"
|
|
);
|
|
|
|
assert_eq!(actual.out, "-236")
|
|
}
|
|
|
|
#[test]
|
|
fn read_ini_with_missing_session() {
|
|
Playground::setup("from ini with missiong session", |dirs, sandbox| {
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
"some_missing.ini",
|
|
r#"
|
|
min-width=450
|
|
max-width=820
|
|
[normal]
|
|
sound-file=/usr/share/sounds/freedesktop/stereo/dialog-information.oga
|
|
[critical]
|
|
border-color=FAB387ff
|
|
default-timeout=20
|
|
sound-file=/usr/share/sounds/freedesktop/stereo/dialog-warning.oga
|
|
"#,
|
|
)]);
|
|
|
|
let cwd = dirs.test();
|
|
let actual = nu_with_plugins!(
|
|
cwd: cwd,
|
|
plugin: ("nu_plugin_formats"),
|
|
r#"open some_missing.ini | get "".min-width "#
|
|
);
|
|
|
|
assert_eq!(actual.out, "450");
|
|
})
|
|
}
|