mirror of
https://github.com/nushell/nushell
synced 2024-12-26 13:03:07 +00:00
Migrate commands_test
This commit is contained in:
parent
abac7cf746
commit
f82cc4291f
2 changed files with 41 additions and 42 deletions
|
@ -13,49 +13,48 @@ fn lines() {
|
|||
assert_eq!(output, "rustyline");
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// fn save_figures_out_intelligently_where_to_write_out_with_metadata() {
|
||||
// let sandbox = Playground::setup_for("save_smart_test")
|
||||
// .with_files(vec![FileWithContent(
|
||||
// "cargo_sample.toml",
|
||||
// r#"
|
||||
// [package]
|
||||
// name = "nu"
|
||||
// version = "0.1.1"
|
||||
// authors = ["Yehuda Katz <wycats@gmail.com>"]
|
||||
// description = "A shell for the GitHub era"
|
||||
// license = "ISC"
|
||||
// edition = "2018"
|
||||
// "#,
|
||||
// )])
|
||||
// .test_dir_name();
|
||||
#[test]
|
||||
fn save_figures_out_intelligently_where_to_write_out_with_metadata() {
|
||||
Playground::setup("save_smart_test", |dirs, playground| {
|
||||
playground
|
||||
.with_files(vec![FileWithContent(
|
||||
"cargo_sample.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "nu"
|
||||
version = "0.1.1"
|
||||
authors = ["Yehuda Katz <wycats@gmail.com>"]
|
||||
description = "A shell for the GitHub era"
|
||||
license = "ISC"
|
||||
edition = "2018"
|
||||
"#,
|
||||
)])
|
||||
.test_dir_name();
|
||||
|
||||
// let full_path = format!("{}/{}", Playground::root(), sandbox);
|
||||
// let subject_file = format!("{}/{}", full_path, "cargo_sample.toml");
|
||||
let subject_file = dirs.test().join("cargo_sample.toml");
|
||||
|
||||
// nu!(
|
||||
// _output,
|
||||
// cwd(&Playground::root()),
|
||||
// "open save_smart_test/cargo_sample.toml | inc package.version --minor | save"
|
||||
// );
|
||||
nu!(
|
||||
dirs.root(),
|
||||
"open save_smart_test/cargo_sample.toml | inc package.version --minor | save"
|
||||
);
|
||||
|
||||
// let actual = h::file_contents(&subject_file);
|
||||
// assert!(actual.contains("0.2.0"));
|
||||
// }
|
||||
let actual = h::file_contents(&subject_file);
|
||||
assert!(actual.contains("0.2.0"));
|
||||
})
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// fn save_can_write_out_csv() {
|
||||
// let sandbox = Playground::setup_for("save_writes_out_csv_test").test_dir_name();
|
||||
#[test]
|
||||
fn save_can_write_out_csv() {
|
||||
Playground::setup("save_writes_out_csv_test", |dirs, playground| {
|
||||
let expected_file = dirs.test().join("cargo_sample.csv");
|
||||
|
||||
// let full_path = format!("{}/{}", Playground::root(), sandbox);
|
||||
// let expected_file = format!("{}/{}", full_path, "cargo_sample.csv");
|
||||
nu!(
|
||||
dirs.root(),
|
||||
"open {}/cargo_sample.toml | inc package.version --minor | get package | save save_writes_out_csv_test/cargo_sample.csv",
|
||||
dirs.formats()
|
||||
);
|
||||
|
||||
// nu!(
|
||||
// _output,
|
||||
// cwd(&Playground::root()),
|
||||
// "open ../formats/cargo_sample.toml | inc package.version --minor | get package | save save_writes_out_csv_test/cargo_sample.csv"
|
||||
// );
|
||||
|
||||
// let actual = h::file_contents(&expected_file);
|
||||
// assert!(actual.contains("[list list],A shell for the GitHub era,2018,ISC,nu,0.2.0"));
|
||||
// }
|
||||
let actual = h::file_contents(expected_file);
|
||||
assert!(actual.contains("[list list],A shell for the GitHub era,2018,ISC,nu,0.2.0"));
|
||||
})
|
||||
}
|
||||
|
|
|
@ -299,8 +299,8 @@ impl Playground {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn file_contents(full_path: &str) -> String {
|
||||
let mut file = std::fs::File::open(full_path).expect("can not open file");
|
||||
pub fn file_contents(full_path: impl AsRef<Path>) -> String {
|
||||
let mut file = std::fs::File::open(full_path.as_ref()).expect("can not open file");
|
||||
let mut contents = String::new();
|
||||
file.read_to_string(&mut contents)
|
||||
.expect("can not read file");
|
||||
|
|
Loading…
Reference in a new issue