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

Function test_view

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

Source from the content-addressed store, hash-verified

923
924 #[tokio::test]
925 async fn test_view() -> anyhow::Result<()> {
926 let db = TestDB::in_memory()?;
927
928 let schema = [("a", AlgebraicType::U8), ("b", AlgebraicType::U8)];
929 let (_, table_id) = tests_utils::create_view_for_test(&db, "my_view", &schema, false)?;
930
931 with_auto_commit(&db, |tx| -> Result<_, DBError> {
932 tests_utils::insert_into_view(&db, tx, table_id, Some(identity_from_u8(1)), product![0u8, 1u8])?;
933 tests_utils::insert_into_view(&db, tx, table_id, Some(identity_from_u8(2)), product![0u8, 2u8])?;
934 Ok(())
935 })?;
936
937 let id = identity_from_u8(2);
938 let auth = AuthCtx::new(Identity::ZERO, id);
939
940 assert_query_results(db.clone(), "select * from my_view", auth, [product![0u8, 2u8]]).await;
941
942 Ok(())
943 }
944
945 #[tokio::test]
946 async fn test_anonymous_view() -> anyhow::Result<()> {

Callers

nothing calls this directly

Calls 8

create_view_for_testFunction · 0.85
with_auto_commitFunction · 0.85
insert_into_viewFunction · 0.85
assert_query_resultsFunction · 0.85
identity_from_u8Function · 0.70
OkFunction · 0.50
newFunction · 0.50
cloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…