2
0
Fork 0
mirror of https://github.com/nushell/nushell synced 2025-02-18 23:18:40 +00:00
nushell/crates/nu-command/tests/commands/lines.rs

51 lines
1,010 B
Rust
Raw Normal View History

2019-12-18 07:54:39 +13:00
use nu_test_support::{nu, pipeline};
#[test]
fn lines() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open cargo_sample.toml -r
| lines
| skip while $it != "[dependencies]"
| skip 1
| first
2020-05-24 01:41:30 -05:00
| split column "="
| get column1.0
| str trim
"#
));
assert_eq!(actual.out, "rustyline");
}
2020-07-04 17:20:58 -07:00
#[test]
fn lines_proper_buffering() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open lines_test.txt -r
| lines
| str length
2022-02-04 11:34:01 -06:00
| to json -r
2020-07-04 17:20:58 -07:00
"#
));
2021-01-08 14:45:25 +13:00
assert_eq!(actual.out, "[8193,3]");
2020-07-04 17:20:58 -07:00
}
#[test]
fn lines_multi_value_split() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open sample-simple.json
| get first second
| lines
| length
"#
));
2022-02-04 11:34:01 -06:00
assert_eq!(actual.out, "6");
}