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

Function test_update

crates/core/src/sql/execute.rs:1365–1392  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1363
1364 #[test]
1365 fn test_update() -> ResultTest<()> {
1366 let (db, input) = create_data(1)?;
1367
1368 run_for_testing(&db, "INSERT INTO inventory (inventory_id, name) VALUES (2, 't2')")?;
1369 run_for_testing(&db, "INSERT INTO inventory (inventory_id, name) VALUES (3, 't3')")?;
1370
1371 run_for_testing(&db, "UPDATE inventory SET name = 'c2' WHERE inventory_id = 2")?;
1372
1373 let result = run_for_testing(&db, "SELECT * FROM inventory WHERE inventory_id = 2")?;
1374
1375 let mut change = input;
1376 change.data.clear();
1377 change.data.push(product![2u64, "c2"]);
1378
1379 assert_eq!(result, change.data, "Update Inventory 2");
1380
1381 run_for_testing(&db, "UPDATE inventory SET name = 'c3'")?;
1382
1383 let result = run_for_testing(&db, "SELECT * FROM inventory")?;
1384
1385 let updated: Vec<_> = result
1386 .into_iter()
1387 .map(|x| x.field_as_str(1, None).unwrap().to_string())
1388 .collect();
1389 assert_eq!(vec!["c3"; 3], updated);
1390
1391 Ok(())
1392 }
1393
1394 #[test]
1395 fn test_multi_column() -> ResultTest<()> {

Callers

nothing calls this directly

Calls 11

create_dataFunction · 0.85
run_for_testingFunction · 0.85
field_as_strMethod · 0.80
clearMethod · 0.65
OkFunction · 0.50
pushMethod · 0.45
collectMethod · 0.45
mapMethod · 0.45
into_iterMethod · 0.45
to_stringMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…