nushell/crates/nu-command/tests/format_conversions/yaml.rs
Darren Schroeder 34c09d8b35
manually revert from serde_yml to serde_yaml (#14987)
# Description

This reverts back to serde_yaml from serde_yml.
Closes https://github.com/nushell/nushell/issues/14934

Reopen https://github.com/nushell/nushell/pull/14630

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the
tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
2025-02-02 19:42:04 -06:00

67 lines
1.4 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 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());
}