mirror of
https://github.com/nushell/nushell.git
synced 2025-04-21 19:58:21 +02:00
# Description This fixes #15240, which can be closed after merge. # User-Facing Changes - user get now use `to yml` -> exactly the same as `to yaml`  # Tests + Formatting Cargo fmt and clippy 🆗 I added a test in the only place I could find where `to yaml` was already tested. I didn't see the `save.rs::convert_to_extension` function tested anywhere, but maybe I missed it. # After Submitting Not sure this needs an update on the documentation ❓ What do you suggest? --------- Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
82 lines
1.7 KiB
Rust
82 lines
1.7 KiB
Rust
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn table_to_yaml_text_and_from_yaml_text_back_into_table() {
|
|
let actual = nu!(
|
|
cwd: "tests/fixtures/formats", pipeline(
|
|
r#"
|
|
open appveyor.yml
|
|
| to yaml
|
|
| from yaml
|
|
| get environment.global.PROJECT_NAME
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "nushell");
|
|
}
|
|
|
|
#[test]
|
|
fn table_to_yml_text_and_from_yml_text_back_into_table() {
|
|
let actual = nu!(
|
|
cwd: "tests/fixtures/formats", pipeline(
|
|
r#"
|
|
open appveyor.yml
|
|
| to yml
|
|
| from yml
|
|
| get environment.global.PROJECT_NAME
|
|
"#
|
|
));
|
|
|
|
assert_eq!(actual.out, "nushell");
|
|
}
|
|
|
|
#[test]
|
|
fn convert_dict_to_yaml_with_boolean_key() {
|
|
let actual = nu!(pipeline(
|
|
r#"
|
|
"true: BooleanKey " | from yaml
|
|
"#
|
|
));
|
|
assert!(actual.out.contains("BooleanKey"));
|
|
assert!(actual.err.is_empty());
|
|
}
|
|
|
|
#[test]
|
|
fn convert_dict_to_yaml_with_integer_key() {
|
|
let actual = nu!(pipeline(
|
|
r#"
|
|
"200: [] " | from yaml
|
|
"#
|
|
));
|
|
|
|
assert!(actual.out.contains("200"));
|
|
assert!(actual.err.is_empty());
|
|
}
|
|
|
|
#[test]
|
|
fn convert_dict_to_yaml_with_integer_floats_key() {
|
|
let actual = nu!(pipeline(
|
|
r#"
|
|
"2.11: "1" " | from yaml
|
|
"#
|
|
));
|
|
assert!(actual.out.contains("2.11"));
|
|
assert!(actual.err.is_empty());
|
|
}
|
|
|
|
#[test]
|
|
#[ignore]
|
|
fn convert_bool_to_yaml_in_yaml_spec_1_2() {
|
|
let actual = nu!(pipeline(
|
|
r#"
|
|
[y n no On OFF True true false] | to yaml
|
|
"#
|
|
));
|
|
|
|
assert_eq!(
|
|
actual.out,
|
|
"- 'y'- 'n'- 'no'- 'On'- 'OFF'- 'True'- true- false"
|
|
);
|
|
assert!(actual.err.is_empty());
|
|
}
|