mirror of
https://github.com/nushell/nushell.git
synced 2025-06-01 07:35:49 +02:00
Move off 'sum' to internal command 'count' for tests.
This commit is contained in:
parent
96ef478fbc
commit
5ed1ed54a6
@ -7,26 +7,21 @@ use helpers::{Playground, Stub::*};
|
|||||||
fn ls_lists_regular_files() {
|
fn ls_lists_regular_files() {
|
||||||
Playground::setup("ls_test_1", |dirs, sandbox| {
|
Playground::setup("ls_test_1", |dirs, sandbox| {
|
||||||
sandbox.with_files(vec![
|
sandbox.with_files(vec![
|
||||||
EmptyFile("yehuda.10.txt"),
|
EmptyFile("yehuda.txt"),
|
||||||
EmptyFile("jonathan.10.txt"),
|
EmptyFile("jonathan.txt"),
|
||||||
EmptyFile("andres.10.txt"),
|
EmptyFile("andres.txt"),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
cwd: dirs.test(), h::pipeline(
|
cwd: dirs.test(), h::pipeline(
|
||||||
r#"
|
r#"
|
||||||
ls
|
ls
|
||||||
| get name
|
| count
|
||||||
| lines
|
|
||||||
| split-column "."
|
|
||||||
| get Column2
|
|
||||||
| str --to-int
|
|
||||||
| sum
|
|
||||||
| echo $it
|
| echo $it
|
||||||
"#
|
"#
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_eq!(actual, "30");
|
assert_eq!(actual, "3");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,22 +29,17 @@ fn ls_lists_regular_files() {
|
|||||||
fn ls_lists_regular_files_using_asterisk_wildcard() {
|
fn ls_lists_regular_files_using_asterisk_wildcard() {
|
||||||
Playground::setup("ls_test_2", |dirs, sandbox| {
|
Playground::setup("ls_test_2", |dirs, sandbox| {
|
||||||
sandbox.with_files(vec![
|
sandbox.with_files(vec![
|
||||||
EmptyFile("los.1.txt"),
|
EmptyFile("los.txt"),
|
||||||
EmptyFile("tres.1.txt"),
|
EmptyFile("tres.txt"),
|
||||||
EmptyFile("amigos.1.txt"),
|
EmptyFile("amigos.txt"),
|
||||||
EmptyFile("arepas.1.clu"),
|
EmptyFile("arepas.clu"),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
cwd: dirs.test(), h::pipeline(
|
cwd: dirs.test(), h::pipeline(
|
||||||
r#"
|
r#"
|
||||||
ls *.txt
|
ls *.txt
|
||||||
| get name
|
| count
|
||||||
| lines
|
|
||||||
| split-column "."
|
|
||||||
| get Column2
|
|
||||||
| str --to-int
|
|
||||||
| sum
|
|
||||||
| echo $it
|
| echo $it
|
||||||
"#
|
"#
|
||||||
));
|
));
|
||||||
@ -72,16 +62,11 @@ fn ls_lists_regular_files_using_question_mark_wildcard() {
|
|||||||
cwd: dirs.test(), h::pipeline(
|
cwd: dirs.test(), h::pipeline(
|
||||||
r#"
|
r#"
|
||||||
ls *.??.txt
|
ls *.??.txt
|
||||||
| get name
|
| count
|
||||||
| lines
|
|
||||||
| split-column "."
|
|
||||||
| get Column2
|
|
||||||
| str --to-int
|
|
||||||
| sum
|
|
||||||
| echo $it
|
| echo $it
|
||||||
"#
|
"#
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_eq!(actual, "30");
|
assert_eq!(actual, "3");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -7,48 +7,66 @@ use helpers::{Playground, Stub::*};
|
|||||||
fn first_gets_first_rows_by_amount() {
|
fn first_gets_first_rows_by_amount() {
|
||||||
Playground::setup("first_test_1", |dirs, sandbox| {
|
Playground::setup("first_test_1", |dirs, sandbox| {
|
||||||
sandbox.with_files(vec![
|
sandbox.with_files(vec![
|
||||||
EmptyFile("los.1.txt"),
|
EmptyFile("los.txt"),
|
||||||
EmptyFile("tres.1.txt"),
|
EmptyFile("tres.txt"),
|
||||||
EmptyFile("amigos.1.txt"),
|
EmptyFile("amigos.txt"),
|
||||||
EmptyFile("arepas.1.clu"),
|
EmptyFile("arepas.clu"),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
cwd: dirs.test(), h::pipeline(
|
cwd: dirs.test(), h::pipeline(
|
||||||
r#"
|
r#"
|
||||||
ls
|
ls
|
||||||
| get name
|
| first 3
|
||||||
| first 2
|
| count
|
||||||
| split-column "."
|
|
||||||
| get Column2
|
|
||||||
| str --to-int
|
|
||||||
| sum
|
|
||||||
| echo $it
|
| echo $it
|
||||||
"#
|
"#
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_eq!(actual, "2");
|
assert_eq!(actual, "3");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn first_gets_first_row_when_no_amount_given() {
|
fn first_gets_all_rows_if_amount_higher_than_all_rows() {
|
||||||
Playground::setup("first_test_2", |dirs, sandbox| {
|
Playground::setup("first_test_2", |dirs, sandbox| {
|
||||||
sandbox.with_files(vec![EmptyFile("los-tres-amigos.PASSTEST.txt")]);
|
sandbox.with_files(vec![
|
||||||
|
EmptyFile("los.txt"),
|
||||||
|
EmptyFile("tres.txt"),
|
||||||
|
EmptyFile("amigos.txt"),
|
||||||
|
EmptyFile("arepas.clu"),
|
||||||
|
]);
|
||||||
|
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
cwd: dirs.test(), h::pipeline(
|
cwd: dirs.test(), h::pipeline(
|
||||||
r#"
|
r#"
|
||||||
ls
|
ls
|
||||||
| get name
|
| first 99
|
||||||
| first
|
| count
|
||||||
| split-column "."
|
|
||||||
| get Column2
|
|
||||||
| echo $it
|
| echo $it
|
||||||
"#
|
"#
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_eq!(actual, "PASSTEST");
|
assert_eq!(actual, "4");
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn first_gets_first_row_when_no_amount_given() {
|
||||||
|
Playground::setup("first_test_3", |dirs, sandbox| {
|
||||||
|
sandbox.with_files(vec![EmptyFile("caballeros.txt"), EmptyFile("arepas.clu")]);
|
||||||
|
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: dirs.test(), h::pipeline(
|
||||||
|
r#"
|
||||||
|
ls
|
||||||
|
| first
|
||||||
|
| count
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
|
assert_eq!(actual, "1");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user