From 0ab0f2761feeb2e47d897d2e1f94be3092c651cf Mon Sep 17 00:00:00 2001 From: Niyaz Nigmatullin Date: Mon, 18 Jul 2022 00:22:01 +0300 Subject: [PATCH] tests/ln: add test for same file --- tests/by-util/test_ln.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/by-util/test_ln.rs b/tests/by-util/test_ln.rs index 042aa1e5d..aabec0352 100644 --- a/tests/by-util/test_ln.rs +++ b/tests/by-util/test_ln.rs @@ -702,3 +702,16 @@ fn test_hard_logical_dir_fail() { .fails() .stderr_contains("failed to link 'link-to-dir'"); } + +#[test] +fn test_symlink_remove_existing_same_src_and_dest() { + let (at, mut ucmd) = at_and_ucmd!(); + at.touch("a"); + at.write("a", "sample"); + ucmd.args(&["-sf", "a", "a"]) + .fails() + .code_is(1) + .stderr_contains("Same file"); + assert!(at.file_exists("a") && !at.symlink_exists("a")); + assert_eq!(at.read("a"), "sample"); +}