diff --git a/crates/nu-cmd-lang/src/example_support.rs b/crates/nu-cmd-lang/src/example_support.rs index c4094df64b..4bdbab952e 100644 --- a/crates/nu-cmd-lang/src/example_support.rs +++ b/crates/nu-cmd-lang/src/example_support.rs @@ -167,9 +167,9 @@ pub fn check_example_evaluates_to_expected_output( "\x1b[31mError:\x1b[0m The result of example \x1b[34m'{}'\x1b[0m for the command \x1b[34m'{}'\x1b[0m differs from the expected value.\n\n\ Expected: {:?}\n\ Actual: {:?}\n", - example.description, + example.description, cmd_name, - expected, + expected, result ); } diff --git a/crates/nu-command/src/bytes/at.rs b/crates/nu-command/src/bytes/at.rs index ddf0394d16..6c790ff052 100644 --- a/crates/nu-command/src/bytes/at.rs +++ b/crates/nu-command/src/bytes/at.rs @@ -237,35 +237,3 @@ fn read_stream( PipelineData::ByteStream(stream, metadata) } - -#[cfg(test)] -mod tests { - use super::*; - use nu_test_support::nu; - - #[test] - fn test_examples() { - use crate::test_examples; - test_examples(BytesAt {}) - } - - #[test] - fn returns_error_for_relative_range_on_infinite_stream() { - let actual = nu!("nu --testbin iecho 3 | bytes at ..-3"); - assert!( - actual.err.contains( - "Negative range values cannot be used with streams that don't specify a length" - ), - "Expected error message for negative range with infinite stream" - ); - } - - #[test] - fn returns_bytes_for_fixed_range_on_infinite_stream() { - let actual = nu!("nu --testbin iecho 3 | bytes at ..10 | decode"); - assert_eq!( - actual.out, "33333", - "Expected bytes from index 1 to 10, but got different output" - ); - } -} diff --git a/crates/nu-command/tests/commands/bytes/at.rs b/crates/nu-command/tests/commands/bytes/at.rs new file mode 100644 index 0000000000..8e107ce631 --- /dev/null +++ b/crates/nu-command/tests/commands/bytes/at.rs @@ -0,0 +1,21 @@ +use nu_test_support::nu; + +#[test] +fn returns_error_for_relative_range_on_infinite_stream() { + let actual = nu!("nu --testbin iecho 3 | bytes at ..-3"); + assert!( + actual.err.contains( + "Negative range values cannot be used with streams that don't specify a length" + ), + "Expected error message for negative range with infinite stream" + ); +} + +#[test] +fn returns_bytes_for_fixed_range_on_infinite_stream() { + let actual = nu!("nu --testbin iecho 3 | bytes at ..10 | decode"); + assert_eq!( + actual.out, "33333", + "Expected bytes from index 1 to 10, but got different output" + ); +} diff --git a/crates/nu-command/tests/commands/bytes/mod.rs b/crates/nu-command/tests/commands/bytes/mod.rs index 10b2a494f8..f1faaef005 100644 --- a/crates/nu-command/tests/commands/bytes/mod.rs +++ b/crates/nu-command/tests/commands/bytes/mod.rs @@ -1 +1,2 @@ +mod at; mod collect;