refactor: deduplicate make_params test helper (#224) #227

Merged
shahondin1624 merged 1 commits from refactor/issue-224-dedup-make-params into main 2026-03-11 13:30:19 +01:00
7 changed files with 18 additions and 42 deletions

View File

@@ -294,13 +294,7 @@ impl ToolDispatcher {
#[cfg(test)]
mod tests {
use super::*;
fn make_params(pairs: &[(&str, &str)]) -> HashMap<String, String> {
pairs
.iter()
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect()
}
use crate::test_util::make_params;
#[tokio::test]
async fn test_internal_executor_success() {

View File

@@ -211,15 +211,9 @@ impl ToolExecutor for FsReadExecutor {
mod tests {
use super::*;
use std::os::unix::fs::PermissionsExt;
use crate::test_util::make_params;
use tempfile::tempdir;
fn make_params(pairs: &[(&str, &str)]) -> HashMap<String, String> {
pairs
.iter()
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect()
}
#[tokio::test]
async fn test_read_existing_file() {
let dir = tempdir().unwrap();

View File

@@ -117,15 +117,9 @@ impl ToolExecutor for FsWriteExecutor {
mod tests {
use super::*;
use std::os::unix::fs::PermissionsExt;
use crate::test_util::make_params;
use tempfile::tempdir;
fn make_params(pairs: &[(&str, &str)]) -> HashMap<String, String> {
pairs
.iter()
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect()
}
#[tokio::test]
async fn test_write_new_file() {
let dir = tempdir().unwrap();

View File

@@ -297,13 +297,7 @@ fn build_output(
#[cfg(test)]
mod tests {
use super::*;
fn make_params(pairs: &[(&str, &str)]) -> HashMap<String, String> {
pairs
.iter()
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect()
}
use crate::test_util::make_params;
// --- Package name validation ---

View File

@@ -394,13 +394,7 @@ fn build_output(
#[cfg(test)]
mod tests {
use super::*;
fn make_params(pairs: &[(&str, &str)]) -> HashMap<String, String> {
pairs
.iter()
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect()
}
use crate::test_util::make_params;
fn fast_executor() -> RunCodeExecutor {
RunCodeExecutor::with_limits(

View File

@@ -345,13 +345,7 @@ fn build_output(
#[cfg(test)]
mod tests {
use super::*;
fn make_params(pairs: &[(&str, &str)]) -> HashMap<String, String> {
pairs
.iter()
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect()
}
use crate::test_util::make_params;
fn fast_executor() -> RunShellExecutor {
RunShellExecutor::with_limits(

View File

@@ -9,3 +9,15 @@ pub mod loop_detector;
pub mod manifest;
pub mod result_tagger;
pub mod service;
#[cfg(test)]
pub(crate) mod test_util {
use std::collections::HashMap;
pub fn make_params(pairs: &[(&str, &str)]) -> HashMap<String, String> {
pairs
.iter()
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect()
}
}