From ecfed5d7e344c617f582d1d91c7395a210a70192 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 18 Nov 2026 11:14:56 +0000 Subject: files: a test's scratch directory goes when the test ends `scratch_dir` gives a guard (`Scratch`) that removes the directory with all it holds when dropped, the test passing or failing. Each test keeps it for as long as it uses the directory; the dashboard's browser check writes its page into one. --- src/identity.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/identity.rs') diff --git a/src/identity.rs b/src/identity.rs index 1012d23..23c4f0f 100644 --- a/src/identity.rs +++ b/src/identity.rs @@ -118,7 +118,8 @@ mod tests { #[test] fn created_only_when_asked_and_then_kept() { - let path = scratch_dir("identity-create").join("node.key"); + let dir = scratch_dir("identity-create"); + let path = dir.join("node.key"); assert!(NodeKey::load(&path, false).is_err()); assert!(!path.exists()); @@ -138,7 +139,8 @@ mod tests { #[test] fn a_key_of_the_wrong_size_is_refused() { - let path = scratch_dir("identity-size").join("node.key"); + let dir = scratch_dir("identity-size"); + let path = dir.join("node.key"); std::fs::write(&path, [7u8; 16]).unwrap(); assert!(NodeKey::load(&path, true).is_err()); } -- cgit v1.3.1