aboutsummaryrefslogtreecommitdiffstats
path: root/src/identity.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-18 11:14:56 +0000
committertv <tv@krebsco.de>2026-11-18 12:23:19 +0100
commitecfed5d7e344c617f582d1d91c7395a210a70192 (patch)
treeb3bd6e23037220d641aa7ffb500dfa60b12ef2a7 /src/identity.rs
parentb6a2649f54741e88a886fe8f64e916415e8a4b72 (diff)
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.
Diffstat (limited to 'src/identity.rs')
-rw-r--r--src/identity.rs6
1 files changed, 4 insertions, 2 deletions
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());
}