use second_brain_core::{
    kuzu_store::KuzuStore,
    schema::{Memory, MemoryType},
    store::Store,
};

fn memory_with_embedding(content: &str, seed: f32) -> Memory {
    let mut m = Memory::new(
        content.to_string(),
        MemoryType::Semantic,
        "test".to_string(),
        String::new(),
    );
    m.embedding = (0..384).map(|i| seed + i as f32 * 0.001).collect();
    m
}

#[test]
fn all_memories_with_embeddings_returns_populated_embeddings() {
    let store = KuzuStore::in_memory("test-machine-embeddings".to_string()).unwrap();

    for (i, content) in ["alpha note", "beta note", "gamma note"].iter().enumerate() {
        store
            .store_memory(&memory_with_embedding(content, i as f32 + 0.1))
            .unwrap();
    }

    let memories = store.all_memories_with_embeddings().unwrap();

    assert_eq!(memories.len(), 3, "all three stored memories must be returned");
    for m in &memories {
        assert_eq!(
            m.embedding.len(),
            384,
            "each memory must carry its full 384-dim embedding, not the row_to_memory null"
        );
        assert!(
            m.embedding.iter().any(|v| *v != 0.0),
            "embedding must be the stored vector, not all zeros"
        );
    }
}
