From 84b5aa13a0e6e5c8c9884ae3f973e560e7d4c59b Mon Sep 17 00:00:00 2001 From: Namilskyy Date: Mon, 1 Dec 2025 15:14:58 +0300 Subject: Fixed test logic and formatted code --- src/cfg/config.rs | 6 +++++- src/net/http_package.rs | 10 ++++++---- src/pkgtoolkit/pkgtools.rs | 11 ++++------- tests/http_funcs.rs | 1 - tests/pkgtoolkit_funcs.rs | 6 +++--- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/cfg/config.rs b/src/cfg/config.rs index 521ffcc..08cdbd9 100644 --- a/src/cfg/config.rs +++ b/src/cfg/config.rs @@ -71,7 +71,11 @@ impl Config { repo_url: format!("https://mesk.anthrill.i2p/repo/{}/", std::env::consts::ARCH), auto_update: true, destination: (String::from("mesk"), String::from("mesk")), - repo_http_url: format!("http://github.com/Anthrill/repo-mirror/{}", std::env::consts::ARCH).into(), + repo_http_url: format!( + "http://github.com/Anthrill/repo-mirror/{}", + std::env::consts::ARCH + ) + .into(), // Its a hurt place, you need to generate destinations by i2pd and paste here (to mesk.toml) // Better to leave it empty or set it to (mesk, mesk), now destination conn not implemented }, diff --git a/src/net/http_package.rs b/src/net/http_package.rs index 92b5ffc..4b2aefa 100644 --- a/src/net/http_package.rs +++ b/src/net/http_package.rs @@ -47,12 +47,14 @@ impl HTTPPackage { let index_url = repo_url_opt.as_deref().map_or_else( || { - log::warn!("Repository URL is None, please specify it in /etc/mesk/mesk.toml and restart."); - String::new() + log::warn!( + "Repository URL is None, please specify it in /etc/mesk/mesk.toml and restart." + ); + String::new() }, - |repo_url_str| { + |repo_url_str| { if repo_url_str.ends_with(".tar.gz") { - repo_url_str.to_string() + repo_url_str.to_string() } else { format!("{}/INDEX.tar.gz", repo_url_str.trim_end_matches('/')) } diff --git a/src/pkgtoolkit/pkgtools.rs b/src/pkgtoolkit/pkgtools.rs index 0105a11..a0433ac 100644 --- a/src/pkgtoolkit/pkgtools.rs +++ b/src/pkgtoolkit/pkgtools.rs @@ -42,7 +42,7 @@ pub struct InstallMeta { user: String, group: String, mode: String, - //! Cancels the previous fields and installs them using the shell script + // Cancels the previous fields and installs them using the shell script custom_script: Option, } @@ -56,9 +56,9 @@ struct Install { #[allow(dead_code)] #[derive(Deserialize, Debug)] struct Setts { - //! Export environment variables if this needed + // Export environment variables if this needed env: Option, - //! Test the package after installation + // Test the package after installation test: Option, } @@ -306,9 +306,7 @@ impl Package { Self::extract_archive(&path_to_archive)?; let archive_path = Path::new(&path_to_archive); - let archive_dir = archive_path - .parent() - .unwrap_or_else(|| Path::new(".")); + let archive_dir = archive_path.parent().unwrap_or_else(|| Path::new(".")); let install_path = archive_dir.join("INSTALL"); let setts_path = archive_dir.join("SETTS"); @@ -355,7 +353,6 @@ impl Package { log::info!("Validating arch..."); - let install_parsed = match install_content { Ok(v) => v, Err(e) => { diff --git a/tests/http_funcs.rs b/tests/http_funcs.rs index a495b3a..55d8c3c 100644 --- a/tests/http_funcs.rs +++ b/tests/http_funcs.rs @@ -9,7 +9,6 @@ use std::collections::HashMap; use tempfile::TempDir; use tokio; - use log::{debug, info}; #[cfg(test)] diff --git a/tests/pkgtoolkit_funcs.rs b/tests/pkgtoolkit_funcs.rs index 3406844..9c5113e 100644 --- a/tests/pkgtoolkit_funcs.rs +++ b/tests/pkgtoolkit_funcs.rs @@ -1,5 +1,5 @@ -use mesk::pkgtoolkit::pkgtools::{Archs, Package}; use mesk::cfg::config::Config; +use mesk::pkgtoolkit::pkgtools::{Archs, Package}; mod shared; use shared::create_test_config; @@ -42,8 +42,8 @@ mod package_tests { Package::extract_archive(archive_path.to_str().unwrap())?; let config = Config::parse().unwrap(); - let extracted_file_path = std::path::Path::new(&config.paths.cache_dir) - .join("extracted_test_file.txt"); + let extracted_file_path = + std::path::Path::new(&config.paths.cache_dir).join("extracted_test_file.txt"); assert!(extracted_file_path.exists()); let content = fs::read_to_string(extracted_file_path)?; assert_eq!(content, test_file_content); -- cgit v1.2.3