mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-01 10:51:11 +01:00
Tests: linked-profile tests take main's with_profiles temp root
with_profiles on main returns the TempDir root as a third value, so the three new listing tests did not compile after the merge. They now keep their outside files under that root, which removes them on drop.
This commit is contained in:
1 parent
f4d82931ea
commit
0ae5a199b2
1 file changed
+5
-10
@@ -1178,11 +1178,11 @@ fn listed_profile(s: &mut Session, name: &str) -> Value {
|
||||
#[test]
|
||||
fn a_linked_profile_is_listed_as_unusable_and_reset_removes_the_link() {
|
||||
use crate::cmd::newdoc::ProfileFile;
|
||||
let (mut s, dir) = with_profiles("linked-listing");
|
||||
let (mut s, dir, root) = with_profiles("linked-listing");
|
||||
s.execute("file.newProfiles.edit", &json!({"name": "Print"})).unwrap();
|
||||
assert_eq!(s.new_doc_profile_file("Print"), ProfileFile::Plain);
|
||||
assert!(listed_profile(&mut s, "Print").get("unusable").is_none());
|
||||
let outside = std::env::temp_dir().join(format!("vc-newdoc-profile-linked-{}.vectorcraft", std::process::id()));
|
||||
let outside = root.join("outside.vectorcraft");
|
||||
std::fs::rename(dir.join("Print.vectorcraft"), &outside).unwrap();
|
||||
std::os::unix::fs::symlink(&outside, dir.join("Print.vectorcraft")).unwrap();
|
||||
|
||||
@@ -1197,29 +1197,25 @@ fn a_linked_profile_is_listed_as_unusable_and_reset_removes_the_link() {
|
||||
assert_eq!(s.execute("file.newProfiles.reset", &json!({"name": "Print"})).unwrap()["reset"], true);
|
||||
assert!(std::fs::symlink_metadata(dir.join("Print.vectorcraft")).is_err() && outside.is_file());
|
||||
assert_eq!(s.new_doc_profile_file("Print"), ProfileFile::None);
|
||||
let _ = std::fs::remove_file(&outside);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn a_profile_link_to_nothing_is_listed_and_edit_does_not_write_through_it() {
|
||||
let (mut s, dir) = with_profiles("dangling");
|
||||
let (mut s, dir, root) = with_profiles("dangling");
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let outside = std::env::temp_dir().join(format!("vc-newdoc-profile-dangling-{}.vectorcraft", std::process::id()));
|
||||
let _ = std::fs::remove_file(&outside);
|
||||
let outside = root.join("outside.vectorcraft");
|
||||
std::os::unix::fs::symlink(&outside, dir.join("Web.vectorcraft")).unwrap();
|
||||
let p = listed_profile(&mut s, "Web");
|
||||
assert_eq!((&p["customized"], &p["unusable"]), (&json!(true), &json!("not a plain file")), "{p}");
|
||||
assert!(s.execute("file.newProfiles.edit", &json!({"name": "Web"})).is_err());
|
||||
assert!(!outside.exists(), "Edit wrote the shipped profile where the link leads");
|
||||
assert_eq!(s.execute("file.newProfiles.reset", &json!({"name": "Web"})).unwrap()["reset"], true);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_folder_in_a_profiles_place_is_listed_as_unusable() {
|
||||
let (mut s, dir) = with_profiles("folder");
|
||||
let (mut s, dir, _root) = with_profiles("folder");
|
||||
std::fs::create_dir_all(dir.join("Mobile.vectorcraft")).unwrap();
|
||||
let p = listed_profile(&mut s, "Mobile");
|
||||
assert_eq!((&p["customized"], &p["unusable"]), (&json!(true), &json!("not a plain file")), "{p}");
|
||||
@@ -1234,7 +1230,6 @@ fn a_folder_in_a_profiles_place_is_listed_as_unusable() {
|
||||
let e = s.execute("file.newProfiles.reset", &json!({"name": "Mobile"})).unwrap_err().to_string();
|
||||
assert!(e.contains("a folder"), "{e}");
|
||||
assert!(dir.join("Mobile.vectorcraft").is_dir());
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user