Add workspace integration tests

- Create tests/workspace_integration.rs with 10 database tests
- Export MockEmbeddings for use in integration tests
- Tests cover: read/write, append, nested paths, delete, memory ops,
  daily log, FTS search, hybrid search, list_all, system_prompt

Requires: DATABASE_URL=postgres://localhost/near_agent_test

Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
Illia Polosukhin
2026-02-02 22:01:09 -08:00
co-authored by Claude Opus 4.5
parent b316a7f4f5
commit 383fb21c07
3 changed files with 356 additions and 4 deletions
+4 -3
View File
@@ -214,19 +214,20 @@ impl EmbeddingProvider for OpenAiEmbeddings {
}
/// A mock embedding provider for testing.
#[cfg(test)]
///
/// Generates deterministic embeddings based on text hash.
/// Useful for unit and integration tests.
pub struct MockEmbeddings {
dimension: usize,
}
#[cfg(test)]
impl MockEmbeddings {
/// Create a new mock embeddings provider with the given dimension.
pub fn new(dimension: usize) -> Self {
Self { dimension }
}
}
#[cfg(test)]
#[async_trait]
impl EmbeddingProvider for MockEmbeddings {
fn dimension(&self) -> usize {
+1 -1
View File
@@ -48,7 +48,7 @@ mod search;
pub use chunker::{ChunkConfig, chunk_document};
pub use document::{MemoryChunk, MemoryDocument, WorkspaceEntry, paths};
pub use embeddings::{EmbeddingProvider, OpenAiEmbeddings};
pub use embeddings::{EmbeddingProvider, MockEmbeddings, OpenAiEmbeddings};
pub use repository::Repository;
pub use search::{SearchConfig, SearchResult};