rust: Move open_file test to utils module

We had essentially the same test in the `lockfile` and `treefile`
modules. Just dedupe those and move it to `utils`.

Closes: #1867
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2019-07-10 20:15:01 -04:00 committed by Atomic Bot
parent 68432e461c
commit 4418589ca1
3 changed files with 11 additions and 22 deletions

View File

@ -180,17 +180,6 @@ mod tests {
Ok(_) => panic!("Expected invalid lockfile"),
}
}
#[test]
fn test_open_file_nonexistent() {
let path = "/usr/share/empty/manifest.json";
match lockfile_parse(path) {
Err(ref e) => assert!(e
.to_string()
.starts_with(format!("Can't open file {:?}:", path).as_str())),
Ok(_) => panic!("Expected nonexistent lockfile error for {}", path),
}
}
}
mod ffi {

View File

@ -1125,17 +1125,6 @@ add-commit-metadata:
assert!(data.get("my-third-key").unwrap().as_i64().unwrap() == 1000);
assert!(data.get("my-fourth-key").unwrap().as_object().unwrap().get("nested").unwrap().as_str().unwrap() == "table");
}
#[test]
fn test_open_file_nonexistent() {
let path = "/usr/share/empty/manifest.yaml";
match treefile_parse(path, None) {
Err(ref e) => assert!(e
.to_string()
.starts_with(format!("Can't open file {:?}:", path).as_str())),
Ok(_) => panic!("Expected nonexistent treefile error for {}", path),
}
}
}
mod ffi {

View File

@ -146,6 +146,17 @@ mod tests {
let r = varsubst("${osvendor}", &subs).unwrap();
assert_eq!(r, "fedora");
}
#[test]
fn test_open_file_nonexistent() {
let path = "/usr/share/empty/manifest.yaml";
match open_file(path) {
Err(ref e) => assert!(e
.to_string()
.starts_with(format!("Can't open file {:?} for reading:", path).as_str())),
Ok(_) => panic!("Expected nonexistent treefile error for {}", path),
}
}
}
mod ffi {