Skip to content

Commit

Permalink
Add test for nest construction
Browse files Browse the repository at this point in the history
  • Loading branch information
afsalthaj committed Apr 2, 2024
1 parent 0d0bd18 commit 3c5d0cc
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions golem-worker-service-base/src/evaluator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,4 +1138,28 @@ mod tests {
};
assert_eq!(result, Ok(expected));
}


#[test]
fn test_evaluation_with_pattern_match_with_nested_construction() {
let worker_response = get_worker_response(
r#"
{
"ok": {
"ids": ["id1", "id2"]
}
}"#,
);

let expr = Expr::from_primitive_string(
"${match worker.response { ok(value) => some(none), none => none }}",
)
.unwrap();
let result = expr.evaluate(&worker_response.result_with_worker_response_key());
let expected = TypeAnnotatedValue::Option {
value: Some(Box::new(TypeAnnotatedValue::Option { typ: AnalysedType::Str, value: None })),
typ: AnalysedType::Option(Box::new(AnalysedType::Str)),
};
assert_eq!(result, Ok(expected));
}
}

0 comments on commit 3c5d0cc

Please sign in to comment.