MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / check_case

Function check_case

atomic-cli/tests/it/git_import_path_audit_test.rs:84–118  ·  view source on GitHub ↗
(states: Vec<Vec<(&str, &[u8], i32)>>, merge: bool)

Source from the content-addressed store, hash-verified

82}
83
84fn 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]
121fn audit_side_parent_space() {

Calls 13

openFunction · 0.85
escape_repo_pathFunction · 0.85
lastMethod · 0.80
get_file_contentMethod · 0.80
initFunction · 0.70
commitFunction · 0.70
importFunction · 0.70
unwrapMethod · 0.45
pathMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected