mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 13:32:45 -05:00
Tests: read-only gate test sets up its cleanup before the first assertion
a_script_gate_does_not_write_over_a_read_only_file created its ReadOnlyFixture guard after two assertions, so a failure in either left the test folder behind. The guard is now created right after the file path is made, before the file is written.
This commit is contained in:
1 parent
46dbb1fb28
commit
81c9588b26
1 file changed
+1
-1
@@ -1200,6 +1200,7 @@ mod tests {
|
||||
fn a_script_gate_does_not_write_over_a_read_only_file() {
|
||||
let (base, _) = folders("gate-read-only");
|
||||
let out = base.join("out/kept.svg");
|
||||
let _cleanup = ReadOnlyFixture { file: out.clone(), folder: base.clone() };
|
||||
std::fs::write(&out, "<svg/>").unwrap();
|
||||
let gate = ScriptGate {
|
||||
read: ScriptScope::default(),
|
||||
@@ -1216,7 +1217,6 @@ mod tests {
|
||||
let document_write = || with_script_gate(documents.clone(), || check_write(&kept).is_ok());
|
||||
assert_eq!(check(&kept), (true, true));
|
||||
assert!(document_write(), "an open document's file is written");
|
||||
let _cleanup = ReadOnlyFixture { file: out.clone(), folder: base.clone() };
|
||||
let mut perms = std::fs::metadata(&out).unwrap().permissions();
|
||||
perms.set_readonly(true);
|
||||
std::fs::set_permissions(&out, perms).unwrap();
|
||||
|
||||
Reference in new issue
Block a user