Assert columnar row count equals `expected`. An empty or missing collection counts as 0.
(
core: &mut CoreLoop,
tx: &mut Producer<BridgeRequest>,
rx: &mut Consumer<BridgeResponse>,
collection: &str,
expected: i64,
)
| 348 | /// Assert columnar row count equals `expected`. |
| 349 | /// An empty or missing collection counts as 0. |
| 350 | pub fn assert_columnar_count( |
| 351 | core: &mut CoreLoop, |
| 352 | tx: &mut Producer<BridgeRequest>, |
| 353 | rx: &mut Consumer<BridgeResponse>, |
| 354 | collection: &str, |
| 355 | expected: i64, |
| 356 | ) { |
| 357 | let payload = send_ok(core, tx, rx, columnar_count(collection)); |
| 358 | let json = payload_json(&payload); |
| 359 | let val: serde_json::Value = serde_json::from_str(&json).unwrap_or(serde_json::Value::Null); |
| 360 | let count = val |
| 361 | .as_array() |
| 362 | .and_then(|a| a.first()) |
| 363 | .and_then(|row| row.get("count(*)")) |
| 364 | .and_then(|v| v.as_i64()) |
| 365 | .unwrap_or(0); // empty array = no rows = 0 |
| 366 | assert_eq!( |
| 367 | count, expected, |
| 368 | "columnar {collection} count: expected {expected}, got {count}; json={json}" |
| 369 | ); |
| 370 | } |
| 371 | |
| 372 | /// Assert timeseries row count equals `expected`. |
| 373 | pub fn assert_ts_count( |