Some checks are pending
Rhai Tests / Run Rhai Tests (push) Waiting to run
- Migrate SAL project from single-crate to monorepo structure - Create independent packages for individual modules - Improve build efficiency and testing capabilities - Update documentation to reflect new structure - Successfully convert the git module to an independent package.
53 lines
1.4 KiB
Rust
53 lines
1.4 KiB
Rust
use sal_git::rhai::*;
|
|
use rhai::Engine;
|
|
|
|
#[test]
|
|
fn test_register_git_module() {
|
|
let mut engine = Engine::new();
|
|
let result = register_git_module(&mut engine);
|
|
assert!(result.is_ok());
|
|
}
|
|
|
|
#[test]
|
|
fn test_git_tree_new_function_registered() {
|
|
let mut engine = Engine::new();
|
|
register_git_module(&mut engine).unwrap();
|
|
|
|
// Test that the function is registered by trying to call it
|
|
// This will fail because /nonexistent doesn't exist, but it proves the function is registered
|
|
let result = engine.eval::<String>(r#"
|
|
let result = "";
|
|
try {
|
|
let git_tree = git_tree_new("/nonexistent");
|
|
result = "success";
|
|
} catch(e) {
|
|
result = "error_caught";
|
|
}
|
|
result
|
|
"#);
|
|
|
|
assert!(result.is_ok());
|
|
assert_eq!(result.unwrap(), "error_caught");
|
|
}
|
|
|
|
#[test]
|
|
fn test_git_clone_function_registered() {
|
|
let mut engine = Engine::new();
|
|
register_git_module(&mut engine).unwrap();
|
|
|
|
// Test that git_clone function is registered and returns an error as expected
|
|
let result = engine.eval::<String>(r#"
|
|
let result = "";
|
|
try {
|
|
git_clone("https://example.com/repo.git");
|
|
result = "unexpected_success";
|
|
} catch(e) {
|
|
result = "error_caught";
|
|
}
|
|
result
|
|
"#);
|
|
|
|
assert!(result.is_ok());
|
|
assert_eq!(result.unwrap(), "error_caught");
|
|
}
|