mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
shred: implemented "--remove" arg (#5790)
This commit is contained in:
parent
247f2e55bd
commit
c867d6bfb1
2 changed files with 158 additions and 24 deletions
|
@ -2,6 +2,9 @@
|
|||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
// spell-checker:ignore wipesync
|
||||
|
||||
use crate::common::util::TestScenario;
|
||||
|
||||
#[test]
|
||||
|
@ -9,8 +12,82 @@ fn test_invalid_arg() {
|
|||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_remove_arg() {
|
||||
new_ucmd!().arg("--remove=unknown").fails().code_is(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_shred() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let file = "test_shred";
|
||||
let file_original_content = "test_shred file content";
|
||||
|
||||
at.write(file, file_original_content);
|
||||
|
||||
ucmd.arg(file).succeeds();
|
||||
|
||||
// File exists
|
||||
assert!(at.file_exists(file));
|
||||
// File is obfuscated
|
||||
assert!(at.read_bytes(file) != file_original_content.as_bytes());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_shred_remove() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let file = "test_shred_remove";
|
||||
at.touch(file);
|
||||
|
||||
ucmd.arg("--remove").arg(file).succeeds();
|
||||
|
||||
// File was deleted
|
||||
assert!(!at.file_exists(file));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_shred_remove_unlink() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let file = "test_shred_remove_unlink";
|
||||
at.touch(file);
|
||||
|
||||
ucmd.arg("--remove=unlink").arg(file).succeeds();
|
||||
|
||||
// File was deleted
|
||||
assert!(!at.file_exists(file));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_shred_remove_wipe() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let file = "test_shred_remove_wipe";
|
||||
at.touch(file);
|
||||
|
||||
ucmd.arg("--remove=wipe").arg(file).succeeds();
|
||||
|
||||
// File was deleted
|
||||
assert!(!at.file_exists(file));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_shred_remove_wipesync() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
let file = "test_shred_remove_wipesync";
|
||||
at.touch(file);
|
||||
|
||||
ucmd.arg("--remove=wipesync").arg(file).succeeds();
|
||||
|
||||
// File was deleted
|
||||
assert!(!at.file_exists(file));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_shred_u() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue