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

Function test_row_limit

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

Source from the content-addressed store, hash-verified

1515
1516 #[test]
1517 fn test_row_limit() -> ResultTest<()> {
1518 let db = TestDB::durable()?;
1519
1520 let table_id = db.create_table_for_test("T", &[("a", AlgebraicType::U8)], &[])?;
1521 with_auto_commit(&db, |tx| -> Result<_, DBError> {
1522 for i in 0..5u8 {
1523 insert(&db, tx, table_id, &product!(i))?;
1524 }
1525 Ok(())
1526 })?;
1527
1528 let server = Identity::from_claims("issuer", "server");
1529 let client = Identity::from_claims("issuer", "client");
1530
1531 let internal_auth = AuthCtx::new(server, server);
1532 let external_auth = AuthCtx::new(server, client);
1533
1534 let tmp_vec = Vec::new();
1535
1536 let rt = db.runtime().expect("runtime should be there");
1537
1538 let run = |db, sql, auth, subs, mut tmp_vec| rt.block_on(run(db, sql, auth, subs, None, &mut tmp_vec));
1539 // No row limit, both queries pass.
1540 assert!(run(
1541 db.clone(),
1542 "SELECT * FROM T".to_string(),
1543 internal_auth.clone(),
1544 None,
1545 tmp_vec.clone()
1546 )
1547 .is_ok());
1548 assert!(run(
1549 db.clone(),
1550 "SELECT * FROM T".to_string(),
1551 external_auth.clone(),
1552 None,
1553 tmp_vec.clone()
1554 )
1555 .is_ok());
1556
1557 // Set row limit.
1558 assert!(run(
1559 db.clone(),
1560 "SET row_limit = 4".to_string(),
1561 internal_auth.clone(),
1562 None,
1563 tmp_vec.clone()
1564 )
1565 .is_ok());
1566
1567 // External query fails.
1568 assert!(run(
1569 db.clone(),
1570 "SELECT * FROM T".to_string(),
1571 internal_auth.clone(),
1572 None,
1573 tmp_vec.clone()
1574 )

Callers

nothing calls this directly

Calls 8

with_auto_commitFunction · 0.85
create_table_for_testMethod · 0.80
runtimeMethod · 0.80
runFunction · 0.70
insertFunction · 0.50
OkFunction · 0.50
newFunction · 0.50
block_onMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…