#[cfg(test)]
#[allow(clippy::module_inception)]
mod tests {
use super::super::*;
#[test]
fn test_compile_options_builder_pattern() {
let options = CompileOptions {
target: Some("aarch64-apple-darwin".to_string()),
profile: "release".to_string(),
cargo_flags: vec!["--features".to_string(), "postgres".to_string()],
jobs: Some(8),
};
assert_eq!(options.target.as_ref().unwrap(), "aarch64-apple-darwin");
assert_eq!(options.profile, "release");
assert_eq!(options.cargo_flags.len(), 2);
assert_eq!(options.jobs.unwrap(), 8);
}
#[test]
fn test_manifest_schema_rust_package() {
use chrono::Utc;
let manifest = manifest_schema::Manifest {
format_version: "2".to_string(),
package: manifest_schema::PackageInfo {
name: "test-workflow".to_string(),
version: "2.1.0".to_string(),
description: Some("Test workflow package".to_string()),
fingerprint: "sha256:test".to_string(),
targets: vec!["linux-x86_64".to_string()],
},
language: manifest_schema::PackageLanguage::Rust,
python: None,
rust: Some(manifest_schema::RustRuntime {
library_path: "libworkflow.dylib".to_string(),
}),
tasks: vec![
manifest_schema::TaskDefinition {
id: "task1".to_string(),
function: "cloacina_execute_task".to_string(),
dependencies: vec![],
description: Some("First task".to_string()),
retries: 0,
timeout_seconds: None,
},
manifest_schema::TaskDefinition {
id: "task2".to_string(),
function: "cloacina_execute_task".to_string(),
dependencies: vec!["task1".to_string()],
description: Some("Second task".to_string()),
retries: 0,
timeout_seconds: None,
},
],
triggers: vec![],
created_at: Utc::now(),
signature: None,
};
assert_eq!(manifest.package.name, "test-workflow");
assert_eq!(manifest.package.version, "2.1.0");
assert!(manifest.rust.is_some());
assert_eq!(manifest.tasks.len(), 2);
assert_eq!(manifest.tasks[1].dependencies, vec!["task1"]);
let json = serde_json::to_string(&manifest).expect("Should serialize");
let deserialized: manifest_schema::Manifest =
serde_json::from_str(&json).expect("Should deserialize");
assert_eq!(deserialized.package.name, manifest.package.name);
assert_eq!(deserialized.tasks.len(), manifest.tasks.len());
}
#[test]
fn test_constants() {
assert_eq!(types::MANIFEST_FILENAME, "manifest.json");
assert!(!types::CLOACINA_VERSION.is_empty());
let version_parts: Vec<&str> = types::CLOACINA_VERSION.split('.').collect();
assert!(
version_parts.len() >= 2,
"Version should have at least major.minor"
);
for part in version_parts.iter().take(2) {
assert!(
part.parse::<u32>().is_ok(),
"Version parts should be numeric: {}",
part
);
}
}
}