MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / test_output

Function test_output

crates/cli/src/subcommands/sql.rs:343–458  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

341
342 #[test]
343 fn test_output() -> Result<(), anyhow::Error> {
344 let duration = Duration::from_micros(1000);
345 let schema = ProductType::from([("a", AlgebraicType::I32), ("b", AlgebraicType::I64)]);
346 let row = make_row(&[AlgebraicValue::I32(1), AlgebraicValue::I64(2)])?;
347 // Verify with and without stats
348 check_output(
349 schema.clone(),
350 vec![&row],
351 SqlStmtStats {
352 rows_inserted: 1,
353 rows_deleted: 1,
354 rows_updated: 1,
355 },
356 None,
357 r#" a | b
358---+---
359 1 | 2"#,
360 )?;
361
362 check_output(
363 schema.clone(),
364 vec![&row],
365 SqlStmtStats {
366 rows_inserted: 1,
367 rows_deleted: 1,
368 rows_updated: 1,
369 },
370 Some(duration),
371 r#" a | b
372---+---
373 1 | 2
374(1 row) [inserted: 1, deleted: 1, updated: 1, server: 1.00ms]
375Roundtrip time: 1.00ms"#,
376 )?;
377
378 // Only a query result
379 check_output(
380 schema.clone(),
381 vec![&row],
382 SqlStmtStats {
383 rows_inserted: 0,
384 rows_deleted: 0,
385 rows_updated: 0,
386 },
387 Some(duration),
388 r#" a | b
389---+---
390 1 | 2
391(1 row) [server: 1.00ms]
392Roundtrip time: 1.00ms"#,
393 )?;
394
395 // Empty table
396 check_output(
397 schema.clone(),
398 vec![],
399 SqlStmtStats {
400 rows_inserted: 0,

Callers

nothing calls this directly

Calls 6

make_rowFunction · 0.85
check_outputFunction · 0.85
I32Class · 0.50
I64Class · 0.50
OkFunction · 0.50
cloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…