summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNamilskyy <alive6863@gmail.com>2025-12-06 20:20:16 +0300
committerNamilskyy <alive6863@gmail.com>2025-12-06 20:20:16 +0300
commite7c49d685efe768c0c1d9c66da7b93b6e118b305 (patch)
treee1bfb33a34c3fe4cb84436e73b48463f5deb8f08 /tests
parentc8520a5cf071eedc966e57abaf4ba2a334df83ee (diff)
Fixed logical errors, tryed to fix tests
Diffstat (limited to 'tests')
-rw-r--r--tests/http_funcs.rs1
-rw-r--r--tests/i2p_functions.rs1
-rw-r--r--tests/pkgtoolkit_funcs.rs32
-rw-r--r--tests/shared.rs12
4 files changed, 34 insertions, 12 deletions
diff --git a/tests/http_funcs.rs b/tests/http_funcs.rs
index 886da10..5a28a98 100644
--- a/tests/http_funcs.rs
+++ b/tests/http_funcs.rs
@@ -167,6 +167,7 @@ mod http_package_tests {
descr: Some("Test".to_string()),
license: Some("MIT".to_string()),
url: "http://example.com/repo/test-pkg.mesk".to_string(),
+ git_repo: None,
};
packages_map.insert("test-pkg".to_string(), pkg);
http_pkg.index_packages = Some(packages_map);
diff --git a/tests/i2p_functions.rs b/tests/i2p_functions.rs
index b07631a..6146e71 100644
--- a/tests/i2p_functions.rs
+++ b/tests/i2p_functions.rs
@@ -64,6 +64,7 @@ mod i2p_package_tests {
descr: Some("Test".to_string()),
license: Some("MIT".to_string()),
url: "http://example.i2p/repo/test-pkg.mesk".to_string(),
+ git_repo: None,
};
packages_map.insert("test-pkg".to_string(), pkg);
i2p_pkg.index_packages = Some(packages_map);
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();
diff --git a/tests/shared.rs b/tests/shared.rs
index 574e8cd..3b6ad70 100644
--- a/tests/shared.rs
+++ b/tests/shared.rs
@@ -1,6 +1,11 @@
use mesk::cfg::config::{Config, Log, Loglevel, Paths, Repo};
pub fn create_test_config(temp_dir_path: &str) -> Config {
+ // Create a unique subdirectory for this specific test to avoid parallel execution conflicts
+ let unique_cache_dir = format!("{}/{}", temp_dir_path, uuid::Uuid::new_v4());
+ let unique_build_dir = format!("{}/{}", unique_cache_dir, "build");
+ let unique_installed_db = format!("{}/{}", unique_cache_dir, "pkgdb");
+
let cfg: Config = Config {
repo: Repo {
repo_url: format!(r"http://mesk.anthrill.i2p/repo/{}", std::env::consts::ARCH),
@@ -8,15 +13,16 @@ pub fn create_test_config(temp_dir_path: &str) -> Config {
.into(),
auto_update: true,
destination: (String::from("mesk"), String::from("mesk")),
+ i2p_http_proxy_port: 4444,
},
log: Log {
log_file: String::from("mesk.log"),
log_level: Loglevel::Info,
},
paths: Paths {
- cache_dir: String::from(temp_dir_path),
- build_dir: String::from(format!("{}/build", String::from(temp_dir_path))),
- installed_db: String::from(format!("{}/pkgdb", String::from(temp_dir_path))),
+ cache_dir: String::from(&unique_cache_dir),
+ build_dir: String::from(&unique_build_dir),
+ installed_db: String::from(&unique_installed_db),
},
};