acts-next 0.15.3

a fast, tiny, extensiable workflow engine
Documentation
use crate::ActFn;
use serde::{Deserialize, Serialize};

#[test]
fn model_act_parse_expose() {
    let text = r#"
    !expose
    a: 1
    b: abc
    "#;
    if let ActFn::Expose(stmt) = serde_yaml::from_str(text).unwrap() {
        assert_eq!(stmt.get::<i32>("a").unwrap(), 1);
        assert_eq!(stmt.get::<String>("b").unwrap(), "abc");
    } else {
        panic!();
    }
}

#[test]
fn model_act_parse_expose_null() {
    let text = r#"
    !expose
    a:
    b:
    "#;
    if let ActFn::Expose(stmt) = serde_yaml::from_str(text).unwrap() {
        assert!(stmt.get::<()>("a").is_some());
        assert!(stmt.get::<()>("b").is_some());
    } else {
        panic!();
    }
}

#[test]
fn model_act_parse_expose_obj() {
    #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
    struct TestModel {
        a: i32,
        b: String,
    }
    let text = r#"
    !expose
    a:
     a: 1
     b: abc
    "#;
    if let ActFn::Expose(stmt) = serde_yaml::from_str(text).unwrap() {
        assert_eq!(
            stmt.get::<TestModel>("a").unwrap(),
            TestModel {
                a: 1,
                b: "abc".to_string()
            }
        );
    } else {
        panic!();
    }
}