Skip to content

Commit 57247c9

Browse files
committed
test: update the virtual WAL Rust test
The test now properly sets the iVersion and pre-main-db-open hook.
1 parent 7c59954 commit 57247c9

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

test/rust_suite/src/virtual_wal.rs

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ mod tests {
5454

5555
#[repr(C)]
5656
struct libsql_wal_methods {
57+
iversion: i32,
5758
open: extern "C" fn(
5859
vfs: *const c_void,
5960
file: *const c_void,
@@ -112,6 +113,7 @@ mod tests {
112113
db: extern "C" fn(wal: *mut Wal, db: *const c_void),
113114
pathname_len: extern "C" fn(orig_len: i32) -> i32,
114115
get_pathname: extern "C" fn(buf: *mut u8, orig: *const u8, orig_len: i32),
116+
pre_main_db_open: extern "C" fn(wal: *mut Wal, name: *const i8) -> i32,
115117
b_uses_shm: i32,
116118
name: *const u8,
117119
p_next: *const c_void,
@@ -327,6 +329,9 @@ mod tests {
327329
extern "C" fn get_pathname(_buf: *mut u8, _orig: *const u8, _orig_len: i32) {
328330
panic!("Should never be called")
329331
}
332+
extern "C" fn pre_main_db_open(_wal: *mut Wal, _name: *const i8) -> i32 {
333+
0
334+
}
330335

331336
#[test]
332337
fn test_vwal_register() {
@@ -338,28 +343,30 @@ mod tests {
338343
let mut pdb: *mut rusqlite::ffi::sqlite3 = std::ptr::null_mut();
339344
let ppdb: *mut *mut rusqlite::ffi::sqlite3 = &mut pdb;
340345
let mut vwal = Box::new(libsql_wal_methods {
341-
open: open,
342-
close: close,
343-
limit: limit,
344-
begin_read: begin_read,
345-
end_read: end_read,
346-
find_frame: find_frame,
347-
read_frame: read_frame,
348-
db_size: db_size,
349-
begin_write: begin_write,
350-
end_write: end_write,
351-
undo: undo,
352-
savepoint: savepoint,
353-
savepoint_undo: savepoint_undo,
354-
frames: frames,
355-
checkpoint: checkpoint,
356-
callback: callback,
357-
exclusive_mode: exclusive_mode,
358-
heap_memory: heap_memory,
359-
file: file,
360-
db: db,
361-
pathname_len: pathname_len,
362-
get_pathname: get_pathname,
346+
iversion: 1,
347+
open,
348+
close,
349+
limit,
350+
begin_read,
351+
end_read,
352+
find_frame,
353+
read_frame,
354+
db_size,
355+
begin_write,
356+
end_write,
357+
undo,
358+
savepoint,
359+
savepoint_undo,
360+
frames,
361+
checkpoint,
362+
callback,
363+
exclusive_mode,
364+
heap_memory,
365+
file,
366+
db,
367+
pathname_len,
368+
get_pathname,
369+
pre_main_db_open,
363370
b_uses_shm: 0,
364371
name: "vwal\0".as_ptr(),
365372
p_next: std::ptr::null(),

0 commit comments

Comments
 (0)