diff --git a/kclvm/driver/src/kpm_update.rs b/kclvm/driver/src/kpm_update.rs index 56e673f0c..5fb384a42 100644 --- a/kclvm/driver/src/kpm_update.rs +++ b/kclvm/driver/src/kpm_update.rs @@ -1,6 +1,6 @@ +use crate::kpm_metadata::get_path_for_executable; use anyhow::{bail, Result}; use std::{path::PathBuf, process::Command}; -use crate::kpm_metadata::get_path_for_executable; const MANIFEST_FILE: &str = "kcl.mod"; @@ -26,7 +26,7 @@ pub(crate) fn update_kcl_module(manifest_path: PathBuf) -> Result<()> { } } None => bail!( - "Manifest file '{}' not found in directory hierarchy", + "Manifest file '{}' not found in directory hierarchy", MANIFEST_FILE ), } @@ -54,4 +54,4 @@ pub(crate) fn lookup_the_nearest_file_dir( None => return None, } } -} \ No newline at end of file +} diff --git a/kclvm/driver/src/tests.rs b/kclvm/driver/src/tests.rs index fe08f347f..7aa14acdf 100644 --- a/kclvm/driver/src/tests.rs +++ b/kclvm/driver/src/tests.rs @@ -9,8 +9,8 @@ use walkdir::WalkDir; use crate::arguments::parse_key_value_pair; use crate::kpm_metadata::{fetch_metadata, fill_pkg_maps_for_k_file, lookup_the_nearest_file_dir}; -use crate::{canonicalize_input_files, expand_input_files, get_pkg_list}; use crate::kpm_update::update_kcl_module; +use crate::{canonicalize_input_files, expand_input_files, get_pkg_list}; #[test] fn test_canonicalize_input_files() { @@ -384,31 +384,33 @@ fn test_get_pkg_list() { #[cfg(test)] // Define a mock structure to simulate the behavior of Command::output - struct MockCommand { - output: Result, +struct MockCommand { + output: Result, } // Define a mock structure to represent the output of Command::output struct MockCommandOutput { - status: std::process::ExitStatus, - stderr: Vec, - } + status: std::process::ExitStatus, + stderr: Vec, +} #[test] fn test_update_kcl_module_success() { let manifest_path = PathBuf::from("path/to/manifest"); - let result = update_kcl_module( manifest_path); - assert!(result.is_ok() - ); + let result = update_kcl_module(manifest_path); + assert!(result.is_ok()); } #[test] fn test_update_kcl_module_failure() { let manifest_path = PathBuf::from("path/to/manifest"); fn mock_command_new_failing(_command: &str) -> MockCommand { - MockCommand { - output: Err(std::io::Error::new(std::io::ErrorKind::Other, "Command failed")), - } + MockCommand { + output: Err(std::io::Error::new( + std::io::ErrorKind::Other, + "Command failed", + )), } - let result = update_kcl_module( manifest_path); + } + let result = update_kcl_module(manifest_path); assert!(result.is_err()); -} \ No newline at end of file +}