Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
louis030195 committed Aug 2, 2024
1 parent 22bc080 commit 2183965
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions screenpipe-server/tests/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ mod tests {
async fn test_insert_and_search_ocr() {
let db = setup_test_db().await;
let _ = db.insert_video_chunk("test_video.mp4").await.unwrap();
let frame_id = db.insert_frame().await.unwrap();
db.insert_ocr_text(frame_id, "Hello, world!", "", "", "").await.unwrap();
let frame_id = db.insert_frame("").await.unwrap();
db.insert_ocr_text(frame_id, "Hello, world!", "", "", "", "")
.await
.unwrap();

let results = db
.search("Hello", ContentType::OCR, 100, 0, None, None)
.search("Hello", ContentType::OCR, 100, 0, None, None, None)
.await
.unwrap();
assert_eq!(results.len(), 1);
Expand All @@ -36,7 +38,7 @@ mod tests {
.unwrap();

let results = db
.search("audio", ContentType::Audio, 100, 0, None, None)
.search("audio", ContentType::Audio, 100, 0, None, None, None)
.await
.unwrap();
assert_eq!(results.len(), 1);
Expand All @@ -54,8 +56,8 @@ mod tests {

// Insert OCR data
let _ = db.insert_video_chunk("test_video.mp4").await.unwrap();
let frame_id = db.insert_frame().await.unwrap();
db.insert_ocr_text(frame_id, "Hello from OCR", "", "", "")
let frame_id = db.insert_frame("").await.unwrap();
db.insert_ocr_text(frame_id, "Hello from OCR", "", "", "", "")
.await
.unwrap();

Expand All @@ -66,7 +68,7 @@ mod tests {
.unwrap();

let results = db
.search("Hello", ContentType::All, 100, 0, None, None)
.search("Hello", ContentType::All, 100, 0, None, None, None)
.await
.unwrap();
assert_eq!(results.len(), 2);
Expand All @@ -92,8 +94,8 @@ mod tests {

// Insert OCR data
let _ = db.insert_video_chunk("test_video.mp4").await.unwrap();
let frame_id1 = db.insert_frame().await.unwrap();
db.insert_ocr_text(frame_id1, "Hello from OCR 1", "", "", "")
let frame_id1 = db.insert_frame("").await.unwrap();
db.insert_ocr_text(frame_id1, "Hello from OCR 1", "", "", "", "")
.await
.unwrap();

Expand All @@ -112,8 +114,8 @@ mod tests {
tokio::time::sleep(tokio::time::Duration::from_millis(10)).await;

// Insert remaining data
let frame_id2 = db.insert_frame().await.unwrap();
db.insert_ocr_text(frame_id2, "Hello from OCR 2", "", "", "")
let frame_id2 = db.insert_frame("").await.unwrap();
db.insert_ocr_text(frame_id2, "Hello from OCR 2", "", "", "", "")
.await
.unwrap();

Expand All @@ -132,6 +134,7 @@ mod tests {
0,
Some(start_time),
Some(end_time),
None,
)
.await
.unwrap();
Expand All @@ -147,6 +150,7 @@ mod tests {
0,
Some(mid_time),
Some(end_time),
None,
)
.await
.unwrap();
Expand All @@ -166,6 +170,7 @@ mod tests {
0,
Some(start_time),
Some(end_time),
None,
)
.await
.unwrap();
Expand All @@ -180,6 +185,7 @@ mod tests {
0,
Some(start_time),
Some(end_time),
None,
)
.await
.unwrap();
Expand All @@ -194,8 +200,8 @@ mod tests {

// Insert OCR data
let _ = db.insert_video_chunk("test_video.mp4").await.unwrap();
let frame_id1 = db.insert_frame().await.unwrap();
db.insert_ocr_text(frame_id1, "Hello from OCR 1", "", "", "")
let frame_id1 = db.insert_frame("").await.unwrap();
db.insert_ocr_text(frame_id1, "Hello from OCR 1", "", "", "", "")
.await
.unwrap();

Expand All @@ -212,8 +218,8 @@ mod tests {
tokio::time::sleep(tokio::time::Duration::from_millis(10)).await;

// Insert remaining data
let frame_id2 = db.insert_frame().await.unwrap();
db.insert_ocr_text(frame_id2, "Hello from OCR 2", "", "", "")
let frame_id2 = db.insert_frame("").await.unwrap();
db.insert_ocr_text(frame_id2, "Hello from OCR 2", "", "", "", "")
.await
.unwrap();

Expand All @@ -232,6 +238,7 @@ mod tests {
0,
Some(mid_time),
Some(end_time),
None,
)
.await
.unwrap();
Expand All @@ -250,6 +257,7 @@ mod tests {
ContentType::Audio,
Some(start_time),
Some(end_time),
None,
)
.await
.unwrap();
Expand Down

0 comments on commit 2183965

Please sign in to comment.