Skip to content

Commit

Permalink
make fmt done
Browse files Browse the repository at this point in the history
Signed-off-by: d4v1d03 <[email protected]>
  • Loading branch information
d4v1d03 committed Feb 15, 2024
1 parent ae47cd3 commit 40229cc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
6 changes: 3 additions & 3 deletions kclvm/driver/src/kpm_update.rs
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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
),
}
Expand Down Expand Up @@ -54,4 +54,4 @@ pub(crate) fn lookup_the_nearest_file_dir(
None => return None,
}
}
}
}
30 changes: 16 additions & 14 deletions kclvm/driver/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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<MockCommandOutput, std::io::Error>,
struct MockCommand {
output: Result<MockCommandOutput, std::io::Error>,
}
// Define a mock structure to represent the output of Command::output
struct MockCommandOutput {
status: std::process::ExitStatus,
stderr: Vec<u8>,
}
status: std::process::ExitStatus,
stderr: Vec<u8>,
}

#[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());
}
}

0 comments on commit 40229cc

Please sign in to comment.