1
0
mirror of https://github.com/nushell/nushell.git synced 2025-07-27 03:04:04 +02:00
Files
.cargo
.github
assets
crates
nu-cli
nu-color-config
nu-command
assets
proptest-regressions
src
tests
commands
date
hash_
math
move_
network
path
basename.rs
dirname.rs
exists.rs
expand.rs
join.rs
mod.rs
parse.rs
split.rs
type_.rs
platform
query
random
skip
str_
take
alias.rs
all.rs
any.rs
append.rs
cal.rs
cd.rs
compact.rs
cp.rs
def.rs
default.rs
do_.rs
drop.rs
each.rs
echo.rs
empty.rs
enter.rs
error_make.rs
every.rs
export_def.rs
find.rs
first.rs
flatten.rs
format.rs
g.rs
get.rs
group_by.rs
headers.rs
help.rs
histogram.rs
insert.rs
into_filesize.rs
into_int.rs
last.rs
length.rs
let_.rs
lines.rs
ls.rs
merge.rs
mkdir.rs
mod.rs
n.rs
nu_check.rs
open.rs
p.rs
parse.rs
prepend.rs
print.rs
range.rs
reduce.rs
reject.rs
rename.rs
reverse.rs
rm.rs
roll.rs
rotate.rs
run_external.rs
save.rs
select.rs
semicolon.rs
shells.rs
sort_by.rs
source_env.rs
split_by.rs
split_column.rs
split_row.rs
touch.rs
transpose.rs
uniq.rs
update.rs
upsert.rs
use_.rs
where_.rs
which.rs
with_env.rs
wrap.rs
zip.rs
format_conversions
main.rs
Cargo.toml
LICENSE
build.rs
nu-engine
nu-glob
nu-json
nu-parser
nu-path
nu-plugin
nu-pretty-hex
nu-protocol
nu-system
nu-table
nu-term-grid
nu-test-support
nu-utils
nu_plugin_custom_values
nu_plugin_example
nu_plugin_gstat
nu_plugin_inc
nu_plugin_python
nu_plugin_query
old
README.md
docker
docs
images
pkg_mgrs
samples
src
tests
wix
.gitignore
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Cargo.lock
Cargo.toml
LICENSE
README.md
README.release.txt
build-all-maclin.sh
build-all-windows.cmd
build-all.nu
build.rs
install-all.ps1
install-all.sh
register-plugins.nu
rust-toolchain.toml
uninstall-all.sh
nushell/crates/nu-command/tests/commands/path/join.rs
2022-03-26 07:46:48 +13:00

72 lines
1.5 KiB
Rust

use nu_test_support::{nu, pipeline};
use super::join_path_sep;
#[test]
fn returns_path_joined_with_column_path() {
let actual = nu!(
cwd: "tests", pipeline(
r#"
echo [ [name]; [eggs] ]
| path join spam.txt -c [ name ]
| get name.0
"#
));
let expected = join_path_sep(&["eggs", "spam.txt"]);
assert_eq!(actual.out, expected);
}
#[test]
fn returns_path_joined_from_list() {
let actual = nu!(
cwd: "tests", pipeline(
r#"
echo [ home viking spam.txt ]
| path join
"#
));
let expected = join_path_sep(&["home", "viking", "spam.txt"]);
assert_eq!(actual.out, expected);
}
#[test]
fn drop_one_path_join() {
let actual = nu!(
cwd: "tests", pipeline(
r#"[a, b, c] | drop 1 | path join
"#
));
let expected = join_path_sep(&["a", "b"]);
assert_eq!(actual.out, expected);
}
#[test]
fn appends_slash_when_joined_with_empty_path() {
let actual = nu!(
cwd: "tests", pipeline(
r#"
echo "/some/dir"
| path join ''
"#
));
let expected = join_path_sep(&["/some/dir", ""]);
assert_eq!(actual.out, expected);
}
#[test]
fn returns_joined_path_when_joining_empty_path() {
let actual = nu!(
cwd: "tests", pipeline(
r#"
echo ""
| path join foo.txt
"#
));
assert_eq!(actual.out, "foo.txt");
}