mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
Refactor path commands (#9687)
This commit is contained in:
@ -2,21 +2,6 @@ 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!(
|
||||
|
@ -99,21 +99,6 @@ fn parses_ignoring_extension_gets_stem() {
|
||||
assert_eq!(actual.out, "spam.tar.gz");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_column_path_extension() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo [[home, barn]; ['home/viking/spam.txt', 'barn/cow/moo.png']]
|
||||
| path parse -c [ home barn ]
|
||||
| get barn
|
||||
| get extension.0
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "png");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_into_correct_number_of_columns() {
|
||||
let actual = nu!(
|
||||
|
@ -25,24 +25,3 @@ fn splits_correctly_single_path() {
|
||||
|
||||
assert_eq!(actual.out, "spam.txt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn splits_correctly_with_column_path() {
|
||||
let actual = nu!(
|
||||
cwd: "tests", pipeline(
|
||||
r#"
|
||||
echo [
|
||||
[home, barn];
|
||||
|
||||
['home/viking/spam.txt', 'barn/cow/moo.png']
|
||||
['home/viking/eggs.txt', 'barn/goat/cheese.png']
|
||||
]
|
||||
| path split -c [ home barn ]
|
||||
| get barn
|
||||
| flatten
|
||||
| length
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "6");
|
||||
}
|
||||
|
Reference in New Issue
Block a user