Add more tests for vtab impl

This commit is contained in:
PThorpe92
2025-02-17 23:22:02 -05:00
parent c4f42549f4
commit 7b05f53335
2 changed files with 10 additions and 2 deletions

View File

@@ -16,13 +16,12 @@ register_extension! {
#[derive(VTabModuleDerive, Default)]
pub struct KVStoreVTab;
/// The cursor holds a snapshot of (rowid, key, value) in memory.
/// the cursor holds a snapshot of (rowid, key, value) in memory.
pub struct KVStoreCursor {
rows: Vec<(i64, String, String)>,
index: Option<usize>,
}
/// Implementing the VTabModule trait for KVStoreVTab
impl VTabModule for KVStoreVTab {
type VCursor = KVStoreCursor;
const VTAB_KIND: VTabKind = VTabKind::VirtualTable;

View File

@@ -531,6 +531,15 @@ def test_kv(pipe):
returns_null,
"can delete from empty table without error",
)
for i in range(100):
write_to_pipe(pipe, f"insert into t values ('key{i}', 'val{i}');")
run_test(
pipe, "select count(*) from t;", lambda res: "100" == res, "can insert 100 rows"
)
run_test(pipe, "delete from t limit 96;", returns_null, "can delete 96 rows")
run_test(
pipe, "select count(*) from t;", lambda res: "4" == res, "four rows remain"
)
def main():