(states: Vec<Vec<(&str, &[u8], i32)>>, merge: bool)
| 82 | } |
| 83 | |
| 84 | fn check_case(states: Vec<Vec<(&str, &[u8], i32)>>, merge: bool) { |
| 85 | let root = tempfile::tempdir().unwrap(); |
| 86 | let config = tempfile::tempdir().unwrap(); |
| 87 | let git = GitRepository::init(root.path()).unwrap(); |
| 88 | let mut ids = Vec::new(); |
| 89 | for (i, files) in states.iter().enumerate() { |
| 90 | let parents = if i == 0 { |
| 91 | vec![] |
| 92 | } else if merge && i == states.len() - 1 { |
| 93 | vec![ids[1], ids[2]] |
| 94 | } else if merge && i == 2 { |
| 95 | vec![ids[0]] |
| 96 | } else { |
| 97 | vec![ids[i - 1]] |
| 98 | }; |
| 99 | ids.push(commit(&git, files, &parents)); |
| 100 | } |
| 101 | import(root.path(), &git, *ids.last().unwrap(), config.path()); |
| 102 | let repo = atomic_repository::Repository::open(root.path()).unwrap(); |
| 103 | for (path, bytes, _) in states.last().unwrap() { |
| 104 | // The repository tracks an imported path under its on-disk spelling |
| 105 | // (as native tracking does); a name with a literal `%` keeps its |
| 106 | // escaped identity, so look the path up under either spelling. |
| 107 | let escaped = atomic_repository::escape_repo_path(path.as_bytes()); |
| 108 | let content = repo |
| 109 | .get_file_content(path) |
| 110 | .unwrap() |
| 111 | .or_else(|| repo.get_file_content(&escaped).unwrap()); |
| 112 | assert_eq!( |
| 113 | content.as_deref(), |
| 114 | Some(*bytes), |
| 115 | "path={path} (escaped {escaped})" |
| 116 | ); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | #[test] |
| 121 | fn audit_side_parent_space() { |
no test coverage detected