()
| 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 | ) |
nothing calls this directly
no test coverage detected
searching dependent graphs…