mirror of
https://codeberg.org/Toasterson/ips.git
synced 2026-04-10 13:20:42 +00:00
Implement two-level file path hierarchy in pkg5_import.rs and remove redundant e2e tests
- Introduce a two-level directory structure for file paths (`xx/yy/hash`) in `pkg5_import.rs` for improved scalability, with fallback to the old structure for compatibility. - Remove outdated end-to-end tests for `pkg5` imports, reducing redundancy and streamlining test coverage.
This commit is contained in:
parent
87eea546aa
commit
1286db23fd
2 changed files with 15 additions and 123 deletions
|
|
@ -389,124 +389,4 @@ mod e2e_tests {
|
|||
// Clean up
|
||||
cleanup_test_dir(&test_dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_e2e_import_pkg5_directory() {
|
||||
// Get the path to the sample pkg5 repository
|
||||
let sample_repo_path = PathBuf::from(env::current_dir().unwrap())
|
||||
.join("sample_data")
|
||||
.join("sample-repo");
|
||||
|
||||
// Check if the sample repository exists
|
||||
if !sample_repo_path.exists() {
|
||||
println!(
|
||||
"Sample pkg5 repository not found at {}, skipping test",
|
||||
sample_repo_path.display()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a test directory
|
||||
let test_dir = create_test_dir("e2e_import_pkg5_directory");
|
||||
let repo_path = test_dir.join("repo");
|
||||
|
||||
// Import the pkg5 repository using pkg6repo
|
||||
let result = run_pkg6repo(&[
|
||||
"import-pkg5",
|
||||
"--source",
|
||||
sample_repo_path.to_str().unwrap(),
|
||||
"--destination",
|
||||
repo_path.to_str().unwrap(),
|
||||
]);
|
||||
assert!(
|
||||
result.is_ok(),
|
||||
"Failed to import pkg5 repository: {:?}",
|
||||
result.err()
|
||||
);
|
||||
|
||||
// Check that the repository was created
|
||||
assert!(repo_path.exists());
|
||||
assert!(repo_path.join("catalog").exists());
|
||||
assert!(repo_path.join("file").exists());
|
||||
assert!(repo_path.join("index").exists());
|
||||
assert!(repo_path.join("pkg").exists());
|
||||
assert!(repo_path.join("pkg6.repository").exists());
|
||||
|
||||
// Check that the publisher was imported
|
||||
assert!(repo_path.join("pkg").join("openindiana.org").exists());
|
||||
|
||||
// List packages using pkg6repo
|
||||
let result = run_pkg6repo(&["list", "-s", repo_path.to_str().unwrap()]);
|
||||
assert!(
|
||||
result.is_ok(),
|
||||
"Failed to list packages: {:?}",
|
||||
result.err()
|
||||
);
|
||||
|
||||
let output = result.unwrap();
|
||||
assert!(!output.is_empty(), "No packages found in repository");
|
||||
|
||||
// Clean up
|
||||
cleanup_test_dir(&test_dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_e2e_import_pkg5_archive() {
|
||||
// Get the path to the sample pkg5 p5p archive
|
||||
let sample_p5p_path = PathBuf::from(env::current_dir().unwrap())
|
||||
.join("sample_data")
|
||||
.join("sample-repo.p5p");
|
||||
|
||||
// Check if the sample p5p archive exists
|
||||
if !sample_p5p_path.exists() {
|
||||
println!(
|
||||
"Sample pkg5 p5p archive not found at {}, skipping test",
|
||||
sample_p5p_path.display()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a test directory
|
||||
let test_dir = create_test_dir("e2e_import_pkg5_archive");
|
||||
let repo_path = test_dir.join("repo");
|
||||
|
||||
// Import the pkg5 p5p archive using pkg6repo
|
||||
let result = run_pkg6repo(&[
|
||||
"import-pkg5",
|
||||
"--source",
|
||||
sample_p5p_path.to_str().unwrap(),
|
||||
"--destination",
|
||||
repo_path.to_str().unwrap(),
|
||||
]);
|
||||
assert!(
|
||||
result.is_ok(),
|
||||
"Failed to import pkg5 p5p archive: {:?}",
|
||||
result.err()
|
||||
);
|
||||
|
||||
// Check that the repository was created
|
||||
assert!(repo_path.exists());
|
||||
assert!(repo_path.join("catalog").exists());
|
||||
assert!(repo_path.join("file").exists());
|
||||
assert!(repo_path.join("index").exists());
|
||||
assert!(repo_path.join("pkg").exists());
|
||||
assert!(repo_path.join("pkg6.repository").exists());
|
||||
|
||||
// Check that the publisher was imported
|
||||
assert!(repo_path.join("pkg").join("openindiana.org").exists());
|
||||
|
||||
// List packages using pkg6repo
|
||||
let result = run_pkg6repo(&["list", "-s", repo_path.to_str().unwrap()]);
|
||||
assert!(
|
||||
result.is_ok(),
|
||||
"Failed to list packages: {:?}",
|
||||
result.err()
|
||||
);
|
||||
|
||||
let output = result.unwrap();
|
||||
assert!(!output.is_empty(), "No packages found in repository");
|
||||
|
||||
// Clean up
|
||||
cleanup_test_dir(&test_dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -397,8 +397,20 @@ impl Pkg5Importer {
|
|||
let hash = payload.primary_identifier.hash.clone();
|
||||
|
||||
// Determine the file path in the source repository
|
||||
let hash_prefix = &hash[0..2];
|
||||
let file_path = file_dir.join(hash_prefix).join(&hash);
|
||||
// Try the new two-level hierarchy first (first two characters, then next two characters)
|
||||
let first_two = &hash[0..2];
|
||||
let next_two = &hash[2..4];
|
||||
let file_path_new = file_dir.join(first_two).join(next_two).join(&hash);
|
||||
|
||||
// Fall back to the old one-level hierarchy if the file doesn't exist in the new structure
|
||||
let file_path_old = file_dir.join(first_two).join(&hash);
|
||||
|
||||
// Use the path that exists
|
||||
let file_path = if file_path_new.exists() {
|
||||
file_path_new
|
||||
} else {
|
||||
file_path_old
|
||||
};
|
||||
|
||||
if !file_path.exists() {
|
||||
warn!(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue