Add document embedding and retrieval via a dedicated embedding model #10
1 changed files with 23 additions and 0 deletions
|
|
@ -237,11 +237,29 @@ mod tests {
|
||||||
assert_eq!(documents[1].text, "scanned");
|
assert_eq!(documents[1].text, "scanned");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Unix permission bits are meaningless to a root process — it can read
|
||||||
|
/// anything regardless of mode — so the two `chmod 0o000` tests below
|
||||||
|
/// would fail under a root-run CI container (e.g. an unmodified Docker
|
||||||
|
/// base image) despite the code being correct. Skip rather than assert
|
||||||
|
/// behavior the OS isn't actually enforcing.
|
||||||
|
#[cfg(unix)]
|
||||||
|
fn running_as_root() -> bool {
|
||||||
|
unsafe extern "C" {
|
||||||
|
fn geteuid() -> u32;
|
||||||
|
}
|
||||||
|
unsafe { geteuid() == 0 }
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[test]
|
#[test]
|
||||||
fn collect_documents_skips_an_unreadable_file_inside_a_directory_but_keeps_the_rest() {
|
fn collect_documents_skips_an_unreadable_file_inside_a_directory_but_keeps_the_rest() {
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
|
||||||
|
if running_as_root() {
|
||||||
|
eprintln!("skipping: running as root, chmod 0o000 has no effect");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let dir = tempdir().unwrap();
|
let dir = tempdir().unwrap();
|
||||||
let readable = dir.path().join("readable.txt");
|
let readable = dir.path().join("readable.txt");
|
||||||
let unreadable = dir.path().join("unreadable.txt");
|
let unreadable = dir.path().join("unreadable.txt");
|
||||||
|
|
@ -263,6 +281,11 @@ mod tests {
|
||||||
fn collect_documents_fails_outright_on_an_unreadable_directory() {
|
fn collect_documents_fails_outright_on_an_unreadable_directory() {
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
|
||||||
|
if running_as_root() {
|
||||||
|
eprintln!("skipping: running as root, chmod 0o000 has no effect");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let dir = tempdir().unwrap();
|
let dir = tempdir().unwrap();
|
||||||
std::fs::set_permissions(dir.path(), std::fs::Permissions::from_mode(0o000)).unwrap();
|
std::fs::set_permissions(dir.path(), std::fs::Permissions::from_mode(0o000)).unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue