1
0
mirror of https://github.com/nushell/nushell.git synced 2025-07-17 14:55:09 +02:00
Files
.cargo
.githooks
.github
assets
benches
crates
nu-cli
nu-cmd-base
nu-cmd-dataframe
nu-cmd-extra
nu-cmd-lang
nu-color-config
nu-command
src
tests
commands
assignment
conversions
date
hash_
math
move_
network
path
platform
query
random
skip
str_
take
mod.rs
rows.rs
until.rs
while_.rs
url
alias.rs
all.rs
any.rs
append.rs
break_.rs
cal.rs
cd.rs
compact.rs
config_env_default.rs
config_nu_default.rs
continue_.rs
cp.rs
debug_info.rs
def.rs
default.rs
detect_columns.rs
do_.rs
drop.rs
each.rs
echo.rs
empty.rs
error_make.rs
every.rs
exec.rs
export_def.rs
fill.rs
find.rs
first.rs
flatten.rs
for_.rs
format.rs
generate.rs
get.rs
glob.rs
group_by.rs
headers.rs
help.rs
histogram.rs
insert.rs
inspect.rs
into_datetime.rs
into_filesize.rs
into_int.rs
join.rs
last.rs
length.rs
let_.rs
lines.rs
loop_.rs
ls.rs
match_.rs
merge.rs
mkdir.rs
mktemp.rs
mod.rs
mut_.rs
nu_check.rs
open.rs
par_each.rs
parse.rs
prepend.rs
print.rs
range.rs
redirection.rs
reduce.rs
reject.rs
rename.rs
return_.rs
reverse.rs
rm.rs
roll.rs
rotate.rs
run_external.rs
save.rs
select.rs
semicolon.rs
seq.rs
seq_char.rs
sort.rs
sort_by.rs
source_env.rs
split_by.rs
split_column.rs
split_row.rs
table.rs
to_text.rs
touch.rs
transpose.rs
try_.rs
ucp.rs
umkdir.rs
uniq.rs
uniq_by.rs
update.rs
upsert.rs
use_.rs
where_.rs
which.rs
while_.rs
with_env.rs
wrap.rs
zip.rs
format_conversions
main.rs
Cargo.toml
LICENSE
nu-engine
nu-explore
nu-glob
nu-json
nu-lsp
nu-parser
nu-path
nu-plugin
nu-pretty-hex
nu-protocol
nu-std
nu-system
nu-table
nu-term-grid
nu-test-support
nu-utils
nu_plugin_custom_values
nu_plugin_example
nu_plugin_formats
nu_plugin_gstat
nu_plugin_inc
nu_plugin_python
nu_plugin_query
README.md
docker
scripts
src
tests
wix
.gitattributes
.gitignore
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Cargo.lock
Cargo.toml
Cross.toml
LICENSE
PLATFORM_SUPPORT.md
README.md
rust-toolchain.toml
toolkit.nu
nushell/crates/nu-command/tests/commands/take/until.rs
Stefan Holderbach 656f707a0b Clean up tests containing unnecessary cwd: tokens ()
# Description
The working directory doesn't have to be set for those tests (or would
be the default anyways). When appropriate also remove calls to the
`pipeline()` function. In most places kept the diff minimal and only
removed the superfluous part to not pollute the blame view. With simpler
tests also simplified things to make them more readable overall (this
included removal of the raw string literal).

Work for 
2023-07-17 18:43:51 +02:00

60 lines
1.8 KiB
Rust

use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
#[test]
fn condition_is_met() {
Playground::setup("take_until_test_1", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContentToBeTrimmed(
"caballeros.txt",
r#"
CHICKEN SUMMARY report date: April 29th, 2020
--------------------------------------------------------------------
Chicken Collection,29/04/2020,30/04/2020,31/04/2020
Yellow Chickens,,,
Andrés,1,1,1
JT,1,1,1
Jason,1,1,1
Yehuda,1,1,1
Blue Chickens,,,
Andrés,1,1,2
JT,1,1,2
Jason,1,1,2
Yehuda,1,1,2
Red Chickens,,,
Andrés,1,1,3
JT,1,1,3
Jason,1,1,3
Yehuda,1,1,3
"#,
)]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
open --raw caballeros.txt
| lines
| skip 2
| str trim
| str join (char nl)
| from csv
| skip while {|row| $row."Chicken Collection" != "Blue Chickens" }
| take until {|row| $row."Chicken Collection" == "Red Chickens" }
| skip 1
| into int "31/04/2020"
| get "31/04/2020"
| math sum
"#
));
assert_eq!(actual.out, "8");
})
}
#[test]
fn fail_on_non_iterator() {
let actual = nu!("1 | take until {|row| $row == 2}");
assert!(actual.err.contains("command doesn't support"));
}