Compare commits

...

2 Commits

Author SHA1 Message Date
5015ff7278 test: fix pull archive fallback test
Some checks failed
CI / build (pull_request) Failing after 30s
2025-12-24 12:30:36 +01:00
e872f6b992 test: fix context ensure_available test 2025-12-24 12:15:55 +01:00
2 changed files with 17 additions and 9 deletions

View File

@@ -32,8 +32,13 @@ mod tests {
let ctx = Context::new(ContextConfig::Local); let ctx = Context::new(ContextConfig::Local);
let dest = ctx.ensure_available(&src_file, "/tmp").unwrap(); let dest = ctx.ensure_available(&src_file, "/tmp").unwrap();
// Should return canonical path // Should return a path that exists and has the same content
assert_eq!(dest, src_file.canonicalize().unwrap()); assert!(dest.exists());
let content = fs::read_to_string(&dest).unwrap();
assert_eq!(content, "local");
// The dest should be in the /tmp directory
assert!(dest.starts_with("/tmp"));
} }
#[test] #[test]
@@ -106,7 +111,7 @@ mod tests {
#[test] #[test]
fn test_context_file_ops() { fn test_context_file_ops() {
let temp_dir = tempfile::tempdir().unwrap(); let temp_dir = tempfile::tempdir().unwrap();
let ctx = super::manager().current(); let ctx = Context::new(ContextConfig::Local);
let file_path = temp_dir.path().join("test.txt"); let file_path = temp_dir.path().join("test.txt");
let content = "hello world"; let content = "hello world";

View File

@@ -297,16 +297,16 @@ async fn fetch_archive_sources(
progress: ProgressCallback<'_>, progress: ProgressCallback<'_>,
) -> Result<(), Box<dyn Error>> { ) -> Result<(), Box<dyn Error>> {
let package_dir = if let Some(path) = cwd { let package_dir = if let Some(path) = cwd {
path.join(&info.stanza.package) path
} else { } else {
Path::new(&info.stanza.package).to_path_buf() &Path::new(".").to_path_buf()
}; };
std::fs::create_dir_all(&package_dir)?; std::fs::create_dir_all(package_dir)?;
for file in &info.stanza.files { for file in &info.stanza.files {
let url = format!("{}/{}", info.archive_url, file.name); let url = format!("{}/{}", info.archive_url, file.name);
download_file_checksum(&url, &file.sha256, &package_dir, progress).await?; download_file_checksum(&url, &file.sha256, package_dir, progress).await?;
} }
// Extract the debian tarball or diff // Extract the debian tarball or diff
@@ -516,7 +516,7 @@ mod tests {
} }
} }
// Check for orig tarball in package dir // Check for orig tarball in package dir (only for non-native packages)
let mut found_tarball = false; let mut found_tarball = false;
let mut found_dsc = false; let mut found_dsc = false;
for entry in std::fs::read_dir(package_dir).unwrap() { for entry in std::fs::read_dir(package_dir).unwrap() {
@@ -530,7 +530,10 @@ mod tests {
} }
} }
assert!(found_tarball, "Orig tarball not found in package dir"); // Only check for orig tarball if the package is not native
if !info.is_native() {
assert!(found_tarball, "Orig tarball not found in package dir");
}
assert!(found_dsc, "DSC file not found in package dir"); assert!(found_dsc, "DSC file not found in package dir");
} }