feat: Migrate SAL to Cargo workspace
Some checks failed
Rhai Tests / Run Rhai Tests (push) Has been cancelled
Rhai Tests / Run Rhai Tests (pull_request) Has been cancelled

- Migrate individual modules to independent crates
- Refactor dependencies for improved modularity
- Update build system and testing infrastructure
- Update documentation to reflect new structure
This commit is contained in:
Mahmoud-Emad
2025-06-24 12:39:18 +03:00
parent 8012a66250
commit e125bb6511
54 changed files with 1196 additions and 1582 deletions

View File

@@ -1,19 +1,26 @@
use sal_git::rhai::*;
use rhai::Engine;
use sal_git::rhai::*;
#[test]
fn test_git_clone_with_various_url_formats() {
let mut engine = Engine::new();
register_git_module(&mut engine).unwrap();
let test_cases = vec![
("https://github.com/octocat/Hello-World.git", "HTTPS with .git"),
("https://github.com/octocat/Hello-World", "HTTPS without .git"),
(
"https://github.com/octocat/Hello-World.git",
"HTTPS with .git",
),
(
"https://github.com/octocat/Hello-World",
"HTTPS without .git",
),
// SSH would require key setup: ("git@github.com:octocat/Hello-World.git", "SSH format"),
];
for (url, description) in test_cases {
let script = format!(r#"
let script = format!(
r#"
let result = "";
try {{
let repo = git_clone("{}");
@@ -31,11 +38,18 @@ fn test_git_clone_with_various_url_formats() {
}}
}}
result
"#, url);
"#,
url
);
let result = engine.eval::<String>(&script);
assert!(result.is_ok(), "Failed to execute script for {}: {:?}", description, result);
assert!(
result.is_ok(),
"Failed to execute script for {}: {:?}",
description,
result
);
let outcome = result.unwrap();
// Accept success or git_error (network issues)
assert!(
@@ -51,7 +65,7 @@ fn test_git_clone_with_various_url_formats() {
fn test_git_tree_operations_comprehensive() {
let mut engine = Engine::new();
register_git_module(&mut engine).unwrap();
let script = r#"
let results = [];
@@ -74,7 +88,7 @@ fn test_git_tree_operations_comprehensive() {
results.len()
"#;
let result = engine.eval::<i64>(&script);
assert!(result.is_ok());
assert!(result.unwrap() >= 3, "Should execute at least 3 operations");
@@ -84,7 +98,7 @@ fn test_git_tree_operations_comprehensive() {
fn test_error_message_quality() {
let mut engine = Engine::new();
register_git_module(&mut engine).unwrap();
let script = r#"
let error_msg = "";
try {
@@ -94,11 +108,14 @@ fn test_error_message_quality() {
}
error_msg
"#;
let result = engine.eval::<String>(&script);
assert!(result.is_ok());
let error_msg = result.unwrap();
assert!(error_msg.contains("Git error"), "Error should contain 'Git error'");
assert!(
error_msg.contains("Git error"),
"Error should contain 'Git error'"
);
assert!(error_msg.len() > 10, "Error message should be descriptive");
}