summaryrefslogtreecommitdiff
path: root/tests/pkgtoolkit_funcs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pkgtoolkit_funcs.rs')
-rw-r--r--tests/pkgtoolkit_funcs.rs32
1 files changed, 23 insertions, 9 deletions
diff --git a/tests/pkgtoolkit_funcs.rs b/tests/pkgtoolkit_funcs.rs
index 9b23a17..bc9c22a 100644
--- a/tests/pkgtoolkit_funcs.rs
+++ b/tests/pkgtoolkit_funcs.rs
@@ -79,7 +79,10 @@ user = "root"
group = "root"
mode = "755"
"#;
- let install_path = temp_dir.path().join("INSTALL");
+ let pkg_name = "test-pkg"; // Match the name in install_content
+ let temp_pkg_dir = temp_dir.path().join(pkg_name);
+ fs::create_dir(&temp_pkg_dir).unwrap();
+ let install_path = temp_pkg_dir.join("INSTALL");
let mut install_file = fs::File::create(&install_path).unwrap();
install_file.write_all(install_content.as_bytes()).unwrap();
@@ -88,7 +91,7 @@ mode = "755"
let gz_encoder = flate2::write::GzEncoder::new(file, flate2::Compression::default());
let mut tar_builder = tar::Builder::new(gz_encoder);
tar_builder
- .append_path_with_name(&install_path, "INSTALL")
+ .append_dir_all(pkg_name, &temp_pkg_dir)
.unwrap();
tar_builder.into_inner().unwrap().finish().unwrap();
@@ -110,14 +113,18 @@ mode = "755"
let temp_dir = TempDir::new().unwrap();
let _config = create_test_config(temp_dir.path().to_str().unwrap());
+ let pkg_name = "test_pkg";
+ let temp_pkg_dir = temp_dir.path().join(pkg_name);
+ fs::create_dir(&temp_pkg_dir).unwrap();
+ let dummy_path = temp_pkg_dir.join("dummy.txt");
+ fs::write(&dummy_path, "dummy").unwrap();
+
let archive_path = temp_dir.path().join("test_pkg_without_install.tar.gz");
let file = fs::File::create(&archive_path).unwrap();
let gz_encoder = flate2::write::GzEncoder::new(file, flate2::Compression::default());
let mut tar_builder = tar::Builder::new(gz_encoder);
- let dummy_path = temp_dir.path().join("dummy.txt");
- fs::write(&dummy_path, "dummy").unwrap();
tar_builder
- .append_path_with_name(&dummy_path, "dummy.txt")
+ .append_dir_all(pkg_name, &temp_pkg_dir)
.unwrap();
tar_builder.into_inner().unwrap().finish().unwrap();
@@ -143,14 +150,18 @@ mode = "755"
let temp_dir = TempDir::new().unwrap();
let _config = create_test_config(temp_dir.path().to_str().unwrap());
- let install_path = temp_dir.path().join("INSTALL");
+ let pkg_name = "test_pkg";
+ let temp_pkg_dir = temp_dir.path().join(pkg_name);
+ fs::create_dir(&temp_pkg_dir).unwrap();
+ let install_path = temp_pkg_dir.join("INSTALL");
fs::write(&install_path, "").unwrap();
+
let archive_path = temp_dir.path().join("test_pkg_with_empty_install.tar.gz");
let file = fs::File::create(&archive_path).unwrap();
let gz_encoder = flate2::write::GzEncoder::new(file, flate2::Compression::default());
let mut tar_builder = tar::Builder::new(gz_encoder);
tar_builder
- .append_path_with_name(&install_path, "INSTALL")
+ .append_dir_all(pkg_name, &temp_pkg_dir)
.unwrap();
tar_builder.into_inner().unwrap().finish().unwrap();
@@ -197,7 +208,10 @@ mode = "755"
wrong_arch
);
- let install_path = temp_dir.path().join("INSTALL");
+ let pkg_name = "test-pkg";
+ let temp_pkg_dir = temp_dir.path().join(pkg_name);
+ fs::create_dir(&temp_pkg_dir).unwrap();
+ let install_path = temp_pkg_dir.join("INSTALL");
let mut install_file = fs::File::create(&install_path).unwrap();
install_file.write_all(install_content.as_bytes()).unwrap();
@@ -206,7 +220,7 @@ mode = "755"
let gz_encoder = flate2::write::GzEncoder::new(file, flate2::Compression::default());
let mut tar_builder = tar::Builder::new(gz_encoder);
tar_builder
- .append_path_with_name(&install_path, "INSTALL")
+ .append_dir_all(pkg_name, &temp_pkg_dir)
.unwrap();
tar_builder.into_inner().unwrap().finish().unwrap();