rust-pathauditor: make sure we actually test the nested repo case
authorRaphaël Gomès <rgomes@octobus.net>
Thu, 03 Oct 2024 01:52:44 +0200
changeset 52051 503b7688f057
parent 52050 de317a87ea6a
child 52052 db5c202eff36
rust-pathauditor: make sure we actually test the nested repo case This covers the *on-disk* case, where the path itself does not have a `.hg` component.
rust/hg-core/src/utils/path_auditor.rs
--- a/rust/hg-core/src/utils/path_auditor.rs	Wed Oct 02 20:29:48 2024 +0200
+++ b/rust/hg-core/src/utils/path_auditor.rs	Thu Oct 03 01:52:44 2024 +0200
@@ -180,7 +180,7 @@
 #[cfg(test)]
 mod tests {
     use super::*;
-    use std::fs::{create_dir, File};
+    use std::fs::{create_dir, create_dir_all, File};
     use tempfile::tempdir;
 
     #[test]
@@ -203,6 +203,16 @@
             })
         );
 
+        create_dir_all(base_dir_path.join("this/is/nested/.hg")).unwrap();
+        let path = HgPath::new(b"this/is/nested/repo");
+        assert_eq!(
+            auditor.audit_path(path),
+            Err(HgPathError::IsInsideNestedRepo {
+                path: path.to_owned(),
+                nested_repo: HgPathBuf::from_bytes(b"this/is/nested")
+            })
+        );
+
         create_dir(base_dir_path.join("realdir")).unwrap();
         File::create(base_dir_path.join("realdir/realfile")).unwrap();
         // TODO make portable