Migrate commands_test

This commit is contained in:
Yehuda Katz 2019-08-28 10:58:00 -07:00
parent abac7cf746
commit f82cc4291f
2 changed files with 41 additions and 42 deletions

View file

@ -13,49 +13,48 @@ fn lines() {
assert_eq!(output, "rustyline"); assert_eq!(output, "rustyline");
} }
// #[test] #[test]
// fn save_figures_out_intelligently_where_to_write_out_with_metadata() { fn save_figures_out_intelligently_where_to_write_out_with_metadata() {
// let sandbox = Playground::setup_for("save_smart_test") Playground::setup("save_smart_test", |dirs, playground| {
// .with_files(vec![FileWithContent( playground
// "cargo_sample.toml", .with_files(vec![FileWithContent(
// r#" "cargo_sample.toml",
// [package] r#"
// name = "nu" [package]
// version = "0.1.1" name = "nu"
// authors = ["Yehuda Katz <wycats@gmail.com>"] version = "0.1.1"
// description = "A shell for the GitHub era" authors = ["Yehuda Katz <wycats@gmail.com>"]
// license = "ISC" description = "A shell for the GitHub era"
// edition = "2018" license = "ISC"
// "#, edition = "2018"
// )]) "#,
// .test_dir_name(); )])
.test_dir_name();
// let full_path = format!("{}/{}", Playground::root(), sandbox); let subject_file = dirs.test().join("cargo_sample.toml");
// let subject_file = format!("{}/{}", full_path, "cargo_sample.toml");
// nu!( nu!(
// _output, dirs.root(),
// cwd(&Playground::root()), "open save_smart_test/cargo_sample.toml | inc package.version --minor | save"
// "open save_smart_test/cargo_sample.toml | inc package.version --minor | save" );
// );
// let actual = h::file_contents(&subject_file); let actual = h::file_contents(&subject_file);
// assert!(actual.contains("0.2.0")); assert!(actual.contains("0.2.0"));
// } })
}
// #[test] #[test]
// fn save_can_write_out_csv() { fn save_can_write_out_csv() {
// let sandbox = Playground::setup_for("save_writes_out_csv_test").test_dir_name(); 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); nu!(
// let expected_file = format!("{}/{}", full_path, "cargo_sample.csv"); dirs.root(),
"open {}/cargo_sample.toml | inc package.version --minor | get package | save save_writes_out_csv_test/cargo_sample.csv",
dirs.formats()
);
// nu!( let actual = h::file_contents(expected_file);
// _output, assert!(actual.contains("[list list],A shell for the GitHub era,2018,ISC,nu,0.2.0"));
// 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"));
// }

View file

@ -299,8 +299,8 @@ impl Playground {
} }
} }
pub fn file_contents(full_path: &str) -> String { pub fn file_contents(full_path: impl AsRef<Path>) -> String {
let mut file = std::fs::File::open(full_path).expect("can not open file"); let mut file = std::fs::File::open(full_path.as_ref()).expect("can not open file");
let mut contents = String::new(); let mut contents = String::new();
file.read_to_string(&mut contents) file.read_to_string(&mut contents)
.expect("can not read file"); .expect("can not read file");