Skip to content

Commit

Permalink
add test for resolve_pallet_path
Browse files Browse the repository at this point in the history
  • Loading branch information
brunopgalvao committed Mar 26, 2024
1 parent 13189fc commit cd0e864
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,27 @@ pub(crate) fn resolve_pallet_path(path: Option<String>) -> PathBuf {
}
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_resolve_pallet_path_with_no_path() {
let result = resolve_pallet_path(None);
// Should resolve to the current working directory
assert_eq!(result, std::env::current_dir().unwrap());
}

#[test]
fn test_resolve_pallet_path_with_custom_path() {
// Create a temporary directory for the custom pallet path
let custom_path = tempfile::tempdir().expect("Failed to create temp dir");
let custom_path_str = custom_path.path().join("my_pallets").to_str().unwrap().to_string();

let result = resolve_pallet_path(Some(custom_path_str.clone()));

assert_eq!(result, custom_path.path().join("my_pallets"), "Unexpected result path");
}

}

0 comments on commit cd0e864

Please sign in to comment.