(#[case] file_type: TestFileType)
| 471 | |
| 472 | // Run the logic to find the files in question. |
| 473 | let runner = TestRunner { |
| 474 | cache_dir: CacheDir::from(tmp_dir.path().to_owned()), |
| 475 | file_type, |
| 476 | repositories: Some(PackageRepositories::iter().collect()), |
| 477 | }; |
| 478 | let found_files = HashSet::from_iter(runner.find_files_of_type()?.into_iter()); |
| 479 | |
| 480 | assert_eq!( |
| 481 | found_files, expected_files, |
| 482 | "Expected that all created package files are also found." |
| 483 | ); |
| 484 | |
| 485 | Ok(()) |
| 486 | } |
| 487 | |
| 488 | /// Ensure that files can be found in case they're nested inside |
| 489 | /// sub-subdirectories if the directory structure is: |
| 490 | /// `target-dir/databases/${pacman-repo}/${package-name}` |
| 491 | #[rstest] |
| 492 | #[case(TestFileFormat::RemoteFiles)] |
| 493 | #[case(TestFileFormat::RemoteDesc)] |
| 494 | fn test_find_files_for_databases(#[case] file_type: TestFileFormat) -> TestResult { |
| 495 | // Create a temporary directory for testing. |
| 496 | let tmp_dir = tempfile::tempdir()?; |
| 497 | let databases_dir = tmp_dir.path().join(DATABASES_DIR); |
| 498 | create_dir(&databases_dir)?; |
| 499 | |
| 500 | // The list of files we're expecting to find. |
| 501 | let mut expected_files = HashSet::new(); |
| 502 | |
| 503 | // Create a test file for each repo. |
| 504 | for (index, repo) in PackageRepositories::iter().enumerate() { |
| 505 | // Create the repository folder |
| 506 | let repo_dir = databases_dir.join(repo.to_string()); |
| 507 | create_dir(&repo_dir)?; |
| 508 | |
| 509 | // Create a package subfolder inside that repository folder. |
| 510 | let pkg = PKG_NAMES[index]; |
| 511 | let pkg_dir = repo_dir.join(pkg); |
| 512 | create_dir(&pkg_dir)?; |
| 513 | |
| 514 | // Touch the file inside the package folder. |
| 515 | let file_path = pkg_dir.join(file_type.to_string()); |
nothing calls this directly
no test coverage detected