mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
tests/integration: Fix write path test on Windows
The read_at() and write_at() APIs are UNIX specific.
This commit is contained in:
parent
f9967f809a
commit
36a7f76708
1 changed files with 5 additions and 4 deletions
|
@ -1,8 +1,7 @@
|
||||||
use crate::common::{self, maybe_setup_tracing};
|
use crate::common::{self, maybe_setup_tracing};
|
||||||
use crate::common::{compare_string, do_flush, TempDatabase};
|
use crate::common::{compare_string, do_flush, TempDatabase};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use std::io::Write;
|
use std::io::{Read, Seek, Write};
|
||||||
use std::os::unix::fs::FileExt;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use turso_core::{Connection, Database, Row, Statement, StepResult, Value};
|
use turso_core::{Connection, Database, Row, Statement, StepResult, Value};
|
||||||
|
|
||||||
|
@ -677,14 +676,16 @@ fn test_wal_bad_frame() -> anyhow::Result<()> {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let offset = WAL_HEADER_SIZE + (WAL_FRAME_HEADER_SIZE + 4096) * 2;
|
let offset = WAL_HEADER_SIZE + (WAL_FRAME_HEADER_SIZE + 4096) * 2;
|
||||||
let mut buf = [0u8; WAL_FRAME_HEADER_SIZE];
|
let mut buf = [0u8; WAL_FRAME_HEADER_SIZE];
|
||||||
file.read_at(&mut buf, offset as u64).unwrap();
|
file.seek(std::io::SeekFrom::Start(offset as u64)).unwrap();
|
||||||
|
file.read_exact(&mut buf).unwrap();
|
||||||
dbg!(&buf);
|
dbg!(&buf);
|
||||||
let db_size = u32::from_be_bytes(buf[4..8].try_into().unwrap());
|
let db_size = u32::from_be_bytes(buf[4..8].try_into().unwrap());
|
||||||
dbg!(offset);
|
dbg!(offset);
|
||||||
assert_eq!(db_size, 4);
|
assert_eq!(db_size, 4);
|
||||||
// let's overwrite size_after to be 0 so that we think transaction never finished
|
// let's overwrite size_after to be 0 so that we think transaction never finished
|
||||||
buf[4..8].copy_from_slice(&[0, 0, 0, 0]);
|
buf[4..8].copy_from_slice(&[0, 0, 0, 0]);
|
||||||
file.write_at(&buf, offset as u64).unwrap();
|
file.seek(std::io::SeekFrom::Start(offset as u64)).unwrap();
|
||||||
|
file.write_all(&buf).unwrap();
|
||||||
file.flush().unwrap();
|
file.flush().unwrap();
|
||||||
|
|
||||||
db_path
|
db_path
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue