mirror of
https://github.com/uutils/coreutils
synced 2024-12-24 03:53:16 +00:00
99b39e4237
Although for some tests this adds characters we still use them there because the brevity cost is now worth the benefit in terms of instant, natural-language readability and recognizability for people not familiar with this tests of this module or even the project
46 lines
1.2 KiB
Rust
46 lines
1.2 KiB
Rust
use common::util::*;
|
|
|
|
static UTIL_NAME: &'static str = "link";
|
|
fn at_and_ucmd() -> (AtPath, UCommand) {
|
|
let ts = TestScenario::new(UTIL_NAME);
|
|
let ucmd = ts.ucmd();
|
|
(ts.fixtures, ucmd)
|
|
}
|
|
|
|
#[test]
|
|
fn test_link_existing_file() {
|
|
let (at, mut ucmd) = at_and_ucmd();
|
|
let file = "test_link_existing_file";
|
|
let link = "test_link_existing_file_link";
|
|
|
|
at.touch(file);
|
|
at.write(file, "foobar");
|
|
assert!(at.file_exists(file));
|
|
|
|
ucmd.args(&[file, link]).succeeds().no_stderr();
|
|
assert!(at.file_exists(file));
|
|
assert!(at.file_exists(link));
|
|
assert_eq!(at.read(file), at.read(link));
|
|
}
|
|
|
|
#[test]
|
|
fn test_link_no_circular() {
|
|
let (at, mut ucmd) = at_and_ucmd();
|
|
let link = "test_link_no_circular";
|
|
|
|
ucmd.args(&[link, link]).fails()
|
|
.stderr_is("link: error: No such file or directory (os error 2)\n");
|
|
assert!(!at.file_exists(link));
|
|
}
|
|
|
|
#[test]
|
|
fn test_link_nonexistent_file() {
|
|
let (at, mut ucmd) = at_and_ucmd();
|
|
let file = "test_link_nonexistent_file";
|
|
let link = "test_link_nonexistent_file_link";
|
|
|
|
ucmd.args(&[file, link]).fails()
|
|
.stderr_is("link: error: No such file or directory (os error 2)\n");
|
|
assert!(!at.file_exists(file));
|
|
assert!(!at.file_exists(link));
|
|
}
|