Skip to content

Commit

Permalink
fix(tracing/js): fault_fn not checked (#221)
Browse files Browse the repository at this point in the history
fix a copy/paste error, checking `fault_fn` but used `result_fn`

Signed-off-by: jsvisa <delweng@gmail.com>
  • Loading branch information
jsvisa authored Oct 11, 2024
1 parent f9481b9 commit f19f677
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/tracing/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl JsInspector {
.as_object()
.cloned()
.ok_or(JsInspectorError::FaultFunctionMissing)?;
if !result_fn.is_callable() {
if !fault_fn.is_callable() {
return Err(JsInspectorError::FaultFunctionMissing);
}

Expand Down Expand Up @@ -648,4 +648,17 @@ mod tests {
));
assert!(result.is_err());
}

#[test]
fn test_fault_fn_not_callable() {
let code = r#"
{
result: function() {},
fault: {},
}
"#;
let config = serde_json::Value::Null;
let result = JsInspector::new(code.to_string(), config);
assert!(matches!(result, Err(JsInspectorError::FaultFunctionMissing)));
}
}

0 comments on commit f19f677

Please sign in to comment.