Skip to content

Commit

Permalink
Improve tests using JValue::pointer (#1290)
Browse files Browse the repository at this point in the history
  • Loading branch information
folex authored Aug 2, 2022
1 parent 1a9f7b7 commit c36f3fb
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions particle-node/tests/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1100,21 +1100,22 @@ fn service_stats() {
},
);

use serde_json::Value::Object;

if let Ok([Object(result)]) = client.receive_args().as_deref() {
if let Ok([result]) = client.receive_args().as_deref() {
assert_eq!(result.get("error"), Some(&json!("")));
assert_eq!(result.get("status"), Some(&json!(true)));
// assert_eq!(result.get("result").unwrap().get("functions_stats").unwrap().get(0).unwrap())
let stat = result.get("result").unwrap().get(0).unwrap();
let f_stat = stat.get("functions_stats").unwrap().get(0).unwrap();
assert_eq!(f_stat.get("name"), Some(&json!("not")));

assert_eq!(
result.pointer("/result/0/functions_stats/0/name"),
Some(&json!("not"))
);
assert_eq!(
result.pointer("/result/0/functions_stats/0/stats/success_req_count"),
Some(&json!(1))
);
assert_eq!(
f_stat.get("stats").unwrap().get("success_req_count"),
result.pointer("/result/0/total_stats/success_req_count"),
Some(&json!(1))
);
let total_stat = stat.get("total_stats").unwrap();
assert_eq!(total_stat.get("success_req_count"), Some(&json!(1)));
} else {
panic!("incorrect args: expected single arrays of module memory stats")
}
Expand Down

0 comments on commit c36f3fb

Please sign in to comment.