feat: Convert SAL to a Rust monorepo
Some checks are pending
Rhai Tests / Run Rhai Tests (push) Waiting to run
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.
This commit is contained in:
52
git/tests/rhai_tests.rs
Normal file
52
git/tests/rhai_tests.rs
Normal file
@@ -0,0 +1,52 @@
|
||||
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");
|
||||
}
|
Reference in New Issue
Block a user