diff --git a/internal/runtime/memory/vector/pg_test.go b/internal/runtime/memory/vector/pg_test.go index 1cfcd5c..8c7b89d 100644 --- a/internal/runtime/memory/vector/pg_test.go +++ b/internal/runtime/memory/vector/pg_test.go @@ -89,4 +89,23 @@ func TestPG_RequiresEnv(t *testing.T) { if len(vs) != 1 || len(vs[0]) != 4 { t.Fatalf("Embed => %d vectors, want one 4-dim", len(vs)) } + + // Vectors(增量向量化的读口):命中按位置给出,未命中为 nil —— + // 这条断言顺带验 vector::text 的解析在真实 pgvector 上成立。 + got, err := idx.Vectors(ctx, []string{"b", "missing", "a"}) + if err != nil { + t.Fatalf("Vectors: %v", err) + } + if len(got) != 3 { + t.Fatalf("Vectors 返回 %d 条, want 3", len(got)) + } + if !equalVector(got[0], Vector{0, 1, 0, 0}) { + t.Fatalf("Vectors[0] = %v, want b 的向量", got[0]) + } + if len(got[1]) != 0 { + t.Fatalf("未命中的 id 返回了向量:%v", got[1]) + } + if !equalVector(got[2], Vector{1, 0, 0, 0}) { + t.Fatalf("Vectors[2] = %v, want a 的向量", got[2]) + } }