mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 11:05:40 +02:00
Add back --append
flag to save
command (#4744)
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
use nu_test_support::fs::{file_contents, Stub::FileWithContent};
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
use std::io::Write;
|
||||
|
||||
#[test]
|
||||
fn figures_out_intelligently_where_to_write_out_with_metadata() {
|
||||
@ -48,8 +49,6 @@ fn writes_out_csv() {
|
||||
})
|
||||
}
|
||||
|
||||
// FIXME: jt: needs more work
|
||||
#[ignore]
|
||||
#[test]
|
||||
fn save_append_will_create_file_if_not_exists() {
|
||||
Playground::setup("save_test_3", |dirs, sandbox| {
|
||||
@ -64,6 +63,31 @@ fn save_append_will_create_file_if_not_exists() {
|
||||
|
||||
let actual = file_contents(expected_file);
|
||||
println!("{}", actual);
|
||||
assert!(actual == "hello");
|
||||
assert_eq!(actual, "hello");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn save_append_will_not_overwrite_content() {
|
||||
Playground::setup("save_test_4", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![]);
|
||||
|
||||
let expected_file = dirs.test().join("new-file.txt");
|
||||
|
||||
{
|
||||
let mut file =
|
||||
std::fs::File::create(&expected_file).expect("Failed to create test file");
|
||||
file.write_all("hello ".as_bytes())
|
||||
.expect("Failed to write to test file")
|
||||
}
|
||||
|
||||
nu!(
|
||||
cwd: dirs.root(),
|
||||
r#"echo world | save --append save_test_4/new-file.txt"#,
|
||||
);
|
||||
|
||||
let actual = file_contents(expected_file);
|
||||
println!("{}", actual);
|
||||
assert_eq!(actual, "hello world");
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user