2019-07-16 10:28:55 +00:00
|
|
|
mod helpers;
|
|
|
|
|
2019-07-20 01:18:27 +00:00
|
|
|
use helpers as h;
|
2019-08-29 06:31:56 +00:00
|
|
|
use helpers::{Playground, Stub::*};
|
2019-07-24 04:10:48 +00:00
|
|
|
|
2019-11-25 22:10:09 +00:00
|
|
|
#[test]
|
|
|
|
fn nth_selects_a_row() {
|
|
|
|
Playground::setup("nth_test_1", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![EmptyFile("notes.txt"), EmptyFile("arepas.txt")]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
ls
|
|
|
|
| sort-by name
|
|
|
|
| nth 0
|
|
|
|
| get name
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "arepas.txt");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn nth_selects_many_rows() {
|
|
|
|
Playground::setup("nth_test_2", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![EmptyFile("notes.txt"), EmptyFile("arepas.txt")]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
ls
|
|
|
|
| get name
|
|
|
|
| nth 1 0
|
|
|
|
| count
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "2");
|
|
|
|
});
|
|
|
|
}
|
2019-11-24 09:20:08 +00:00
|
|
|
#[test]
|
2019-11-24 09:21:35 +00:00
|
|
|
fn default_row_data_if_column_missing() {
|
2019-11-24 09:20:08 +00:00
|
|
|
Playground::setup("default_test_1", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
|
|
"los_tres_amigos.json",
|
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"amigos": [
|
|
|
|
{"name": "Yehuda"},
|
|
|
|
{"name": "Jonathan", "rusty_luck": 0},
|
|
|
|
{"name": "Andres", "rusty_luck": 0},
|
|
|
|
{"name":"GorbyPuff"}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
open los_tres_amigos.json
|
|
|
|
| get amigos
|
|
|
|
| default rusty_luck 1
|
2019-12-10 00:05:40 +00:00
|
|
|
| where rusty_luck == 1
|
|
|
|
| count
|
2019-11-24 09:20:08 +00:00
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "2");
|
|
|
|
});
|
|
|
|
}
|
2019-11-23 23:57:12 +00:00
|
|
|
#[test]
|
|
|
|
fn compact_rows_where_given_column_is_empty() {
|
|
|
|
Playground::setup("compact_test_1", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
|
|
"los_tres_amigos.json",
|
|
|
|
r#"
|
|
|
|
{
|
|
|
|
"amigos": [
|
|
|
|
{"name": "Yehuda", "rusty_luck": 1},
|
|
|
|
{"name": "Jonathan", "rusty_luck": 1},
|
|
|
|
{"name": "Andres", "rusty_luck": 1},
|
|
|
|
{"name":"GorbyPuff"}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
open los_tres_amigos.json
|
|
|
|
| get amigos
|
|
|
|
| compact rusty_luck
|
|
|
|
| count
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "3");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
#[test]
|
|
|
|
fn compact_empty_rows_by_default() {
|
2019-11-24 00:07:12 +00:00
|
|
|
Playground::setup("compact_test_2", |dirs, _| {
|
2019-11-23 23:57:12 +00:00
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
echo "[1,2,3,14,null]"
|
|
|
|
| from-json
|
|
|
|
| compact
|
|
|
|
| count
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "4");
|
|
|
|
});
|
|
|
|
}
|
2019-10-20 23:42:07 +00:00
|
|
|
#[test]
|
|
|
|
fn group_by() {
|
|
|
|
Playground::setup("group_by_test_1", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
|
|
"los_tres_caballeros.csv",
|
|
|
|
r#"
|
2019-10-29 21:04:31 +00:00
|
|
|
first_name,last_name,rusty_at,type
|
|
|
|
Andrés,Robalino,10/11/2013,A
|
|
|
|
Jonathan,Turner,10/12/2013,B
|
|
|
|
Yehuda,Katz,10/11/2013,A
|
2019-10-20 23:42:07 +00:00
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
open los_tres_caballeros.csv
|
2019-10-29 21:04:31 +00:00
|
|
|
| group-by rusty_at
|
|
|
|
| get "10/11/2013"
|
2019-10-20 23:42:07 +00:00
|
|
|
| count
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "2");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-11-12 08:38:55 +00:00
|
|
|
#[test]
|
|
|
|
fn histogram() {
|
|
|
|
Playground::setup("histogram_test_1", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
|
|
"los_tres_caballeros.csv",
|
|
|
|
r#"
|
|
|
|
first_name,last_name,rusty_at
|
|
|
|
Andrés,Robalino,Ecuador
|
|
|
|
Jonathan,Turner,Estados Unidos
|
|
|
|
Yehuda,Katz,Estados Unidos
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
open los_tres_caballeros.csv
|
|
|
|
| histogram rusty_at countries
|
|
|
|
| where rusty_at == "Ecuador"
|
|
|
|
| get countries
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "**************************************************");
|
|
|
|
// 50%
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-10-22 05:00:06 +00:00
|
|
|
#[test]
|
|
|
|
fn group_by_errors_if_unknown_column_name() {
|
|
|
|
Playground::setup("group_by_test_2", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
|
|
"los_tres_caballeros.csv",
|
|
|
|
r#"
|
2019-10-29 21:04:31 +00:00
|
|
|
first_name,last_name,rusty_at,type
|
|
|
|
Andrés,Robalino,10/11/2013,A
|
|
|
|
Jonathan,Turner,10/12/2013,B
|
|
|
|
Yehuda,Katz,10/11/2013,A
|
2019-10-22 05:00:06 +00:00
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
let actual = nu_error!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
open los_tres_caballeros.csv
|
|
|
|
| group-by ttype
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert!(actual.contains("Unknown column"));
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-12-03 07:24:49 +00:00
|
|
|
#[test]
|
|
|
|
fn range_selects_a_row() {
|
|
|
|
Playground::setup("range_test_1", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![EmptyFile("notes.txt"), EmptyFile("tests.txt")]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
ls
|
|
|
|
| sort-by name
|
|
|
|
| range 0..0
|
|
|
|
| get name
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "notes.txt");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn range_selects_some_rows() {
|
|
|
|
Playground::setup("range_test_2", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![
|
|
|
|
EmptyFile("notes.txt"),
|
|
|
|
EmptyFile("tests.txt"),
|
|
|
|
EmptyFile("persons.txt"),
|
|
|
|
]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
ls
|
|
|
|
| get name
|
|
|
|
| range 1..2
|
|
|
|
| count
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "2");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-10-29 21:04:31 +00:00
|
|
|
#[test]
|
|
|
|
fn split_by() {
|
|
|
|
Playground::setup("split_by_test_1", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
|
|
|
"los_tres_caballeros.csv",
|
|
|
|
r#"
|
|
|
|
first_name,last_name,rusty_at,type
|
|
|
|
Andrés,Robalino,10/11/2013,A
|
|
|
|
Jonathan,Turner,10/12/2013,B
|
|
|
|
Yehuda,Katz,10/11/2013,A
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
open los_tres_caballeros.csv
|
|
|
|
| group-by rusty_at
|
|
|
|
| split-by type
|
|
|
|
| get A."10/11/2013"
|
|
|
|
| count
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "2");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn split_by_errors_if_no_table_given_as_input() {
|
|
|
|
Playground::setup("split_by_test_2", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![
|
|
|
|
EmptyFile("los.txt"),
|
|
|
|
EmptyFile("tres.txt"),
|
|
|
|
EmptyFile("amigos.txt"),
|
|
|
|
EmptyFile("arepas.clu"),
|
|
|
|
]);
|
|
|
|
|
|
|
|
let actual = nu_error!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
ls
|
|
|
|
| get name
|
|
|
|
| split-by type
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert!(actual.contains("Expected table from pipeline"));
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-09-12 10:22:58 +00:00
|
|
|
#[test]
|
|
|
|
fn first_gets_first_rows_by_amount() {
|
|
|
|
Playground::setup("first_test_1", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![
|
2019-10-15 10:16:47 +00:00
|
|
|
EmptyFile("los.txt"),
|
|
|
|
EmptyFile("tres.txt"),
|
|
|
|
EmptyFile("amigos.txt"),
|
|
|
|
EmptyFile("arepas.clu"),
|
2019-09-12 10:22:58 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
ls
|
2019-10-15 10:16:47 +00:00
|
|
|
| first 3
|
|
|
|
| count
|
2019-09-12 10:22:58 +00:00
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2019-10-15 10:16:47 +00:00
|
|
|
assert_eq!(actual, "3");
|
2019-09-12 10:22:58 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2019-10-15 10:16:47 +00:00
|
|
|
fn first_gets_all_rows_if_amount_higher_than_all_rows() {
|
2019-10-15 09:17:55 +00:00
|
|
|
Playground::setup("first_test_2", |dirs, sandbox| {
|
2019-10-15 10:16:47 +00:00
|
|
|
sandbox.with_files(vec![
|
|
|
|
EmptyFile("los.txt"),
|
|
|
|
EmptyFile("tres.txt"),
|
|
|
|
EmptyFile("amigos.txt"),
|
|
|
|
EmptyFile("arepas.clu"),
|
|
|
|
]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
ls
|
|
|
|
| first 99
|
|
|
|
| count
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
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")]);
|
2019-09-12 10:22:58 +00:00
|
|
|
|
2019-10-15 09:17:55 +00:00
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
ls
|
|
|
|
| first
|
2019-10-15 10:16:47 +00:00
|
|
|
| count
|
2019-10-15 09:17:55 +00:00
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2019-10-15 10:16:47 +00:00
|
|
|
assert_eq!(actual, "1");
|
2019-09-12 10:22:58 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-10-15 10:41:34 +00:00
|
|
|
#[test]
|
|
|
|
fn last_gets_last_rows_by_amount() {
|
|
|
|
Playground::setup("last_test_1", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![
|
|
|
|
EmptyFile("los.txt"),
|
|
|
|
EmptyFile("tres.txt"),
|
|
|
|
EmptyFile("amigos.txt"),
|
|
|
|
EmptyFile("arepas.clu"),
|
|
|
|
]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
ls
|
|
|
|
| last 3
|
|
|
|
| count
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "3");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn last_gets_last_row_when_no_amount_given() {
|
|
|
|
Playground::setup("last_test_2", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![EmptyFile("caballeros.txt"), EmptyFile("arepas.clu")]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
ls
|
|
|
|
| last
|
|
|
|
| count
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "1");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-11-04 15:47:03 +00:00
|
|
|
#[test]
|
|
|
|
fn get() {
|
|
|
|
Playground::setup("get_test_1", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![FileWithContent(
|
|
|
|
"sample.toml",
|
|
|
|
r#"
|
|
|
|
nu_party_venue = "zion"
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
open sample.toml
|
|
|
|
| get nu_party_venue
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "zion");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn get_more_than_one_member() {
|
|
|
|
Playground::setup("get_test_2", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![FileWithContent(
|
|
|
|
"sample.toml",
|
|
|
|
r#"
|
|
|
|
[[fortune_tellers]]
|
|
|
|
name = "Andrés N. Robalino"
|
|
|
|
arepas = 1
|
|
|
|
broken_builds = 0
|
|
|
|
|
|
|
|
[[fortune_tellers]]
|
|
|
|
name = "Jonathan Turner"
|
|
|
|
arepas = 1
|
|
|
|
broken_builds = 1
|
|
|
|
|
|
|
|
[[fortune_tellers]]
|
|
|
|
name = "Yehuda Katz"
|
|
|
|
arepas = 1
|
|
|
|
broken_builds = 1
|
|
|
|
"#,
|
|
|
|
)]);
|
|
|
|
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
|
|
|
open sample.toml
|
|
|
|
| get fortune_tellers
|
|
|
|
| get arepas broken_builds
|
2019-12-10 00:05:40 +00:00
|
|
|
| where $it == 1
|
|
|
|
| count
|
2019-11-04 15:47:03 +00:00
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
|
|
|
assert_eq!(actual, "5");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-07-16 10:28:55 +00:00
|
|
|
#[test]
|
|
|
|
fn lines() {
|
2019-08-29 00:32:42 +00:00
|
|
|
let actual = nu!(
|
2019-08-29 06:31:56 +00:00
|
|
|
cwd: "tests/fixtures/formats", h::pipeline(
|
|
|
|
r#"
|
2019-09-03 00:49:51 +00:00
|
|
|
open cargo_sample.toml --raw
|
|
|
|
| lines
|
|
|
|
| skip-while $it != "[dependencies]"
|
|
|
|
| skip 1
|
|
|
|
| first 1
|
|
|
|
| split-column "="
|
|
|
|
| get Column1
|
|
|
|
| trim
|
2019-08-29 06:31:56 +00:00
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
2019-07-16 10:28:55 +00:00
|
|
|
|
2019-08-29 00:32:42 +00:00
|
|
|
assert_eq!(actual, "rustyline");
|
2019-07-16 10:28:55 +00:00
|
|
|
}
|
|
|
|
|
2019-08-28 17:58:00 +00:00
|
|
|
#[test]
|
|
|
|
fn save_figures_out_intelligently_where_to_write_out_with_metadata() {
|
2019-08-29 00:32:42 +00:00
|
|
|
Playground::setup("save_test_1", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![FileWithContent(
|
|
|
|
"cargo_sample.toml",
|
|
|
|
r#"
|
2019-08-28 17:58:00 +00:00
|
|
|
[package]
|
|
|
|
name = "nu"
|
|
|
|
version = "0.1.1"
|
|
|
|
authors = ["Yehuda Katz <wycats@gmail.com>"]
|
|
|
|
description = "A shell for the GitHub era"
|
|
|
|
license = "ISC"
|
|
|
|
edition = "2018"
|
2019-09-04 02:37:26 +00:00
|
|
|
"#,
|
|
|
|
)]);
|
2019-08-28 17:58:00 +00:00
|
|
|
|
|
|
|
let subject_file = dirs.test().join("cargo_sample.toml");
|
|
|
|
|
|
|
|
nu!(
|
2019-08-29 06:31:56 +00:00
|
|
|
cwd: dirs.root(),
|
2019-12-10 00:05:40 +00:00
|
|
|
"open save_test_1/cargo_sample.toml | save"
|
2019-08-28 17:58:00 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
let actual = h::file_contents(&subject_file);
|
2019-12-10 00:05:40 +00:00
|
|
|
assert!(actual.contains("0.1.1"));
|
2019-08-28 17:58:00 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-10-14 20:30:23 +00:00
|
|
|
#[test]
|
|
|
|
fn it_arg_works_with_many_inputs_to_external_command() {
|
|
|
|
Playground::setup("it_arg_works_with_many_inputs", |dirs, sandbox| {
|
|
|
|
sandbox.with_files(vec![
|
|
|
|
FileWithContent("file1", "text"),
|
|
|
|
FileWithContent("file2", " and more text"),
|
|
|
|
]);
|
|
|
|
|
|
|
|
let (stdout, stderr) = nu_combined!(
|
|
|
|
cwd: dirs.test(), h::pipeline(
|
|
|
|
r#"
|
2019-10-21 15:18:43 +00:00
|
|
|
echo hello world
|
2019-10-14 20:30:23 +00:00
|
|
|
| split-row " "
|
2019-10-21 15:18:43 +00:00
|
|
|
| ^echo $it
|
2019-10-14 20:30:23 +00:00
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2019-10-21 15:18:43 +00:00
|
|
|
#[cfg(windows)]
|
|
|
|
assert_eq!("hello world", stdout);
|
|
|
|
|
|
|
|
#[cfg(not(windows))]
|
|
|
|
assert_eq!("helloworld", stdout);
|
|
|
|
|
2019-10-14 20:30:23 +00:00
|
|
|
assert!(!stderr.contains("No such file or directory"));
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-08-28 17:58:00 +00:00
|
|
|
#[test]
|
|
|
|
fn save_can_write_out_csv() {
|
2019-08-29 00:32:42 +00:00
|
|
|
Playground::setup("save_test_2", |dirs, _| {
|
2019-08-28 17:58:00 +00:00
|
|
|
let expected_file = dirs.test().join("cargo_sample.csv");
|
|
|
|
|
|
|
|
nu!(
|
2019-08-29 06:31:56 +00:00
|
|
|
cwd: dirs.root(),
|
2019-12-10 00:05:40 +00:00
|
|
|
"open {}/cargo_sample.toml | get package | save save_test_2/cargo_sample.csv",
|
2019-08-28 17:58:00 +00:00
|
|
|
dirs.formats()
|
|
|
|
);
|
|
|
|
|
|
|
|
let actual = h::file_contents(expected_file);
|
2019-12-10 00:05:40 +00:00
|
|
|
assert!(actual.contains("[Table],A shell for the GitHub era,2018,ISC,nu,0.1.1"));
|
2019-09-04 02:37:26 +00:00
|
|
|
})
|
|
|
|
}
|