From 8f7017fc0b0714c235db73abaf5032f98c024cb5 Mon Sep 17 00:00:00 2001 From: AskaEth Date: Fri, 30 Oct 2026 08:32:09 +0800 Subject: [PATCH] =?UTF-8?q?test(memory):=20PG=20=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E7=9A=84=20Vectors=20=E8=AF=BB=E5=8F=A3=E7=BA=B3=E5=85=A5=20DB?= =?UTF-8?q?=5FPG=5FURL=20=E7=9C=9F=E5=BA=93=E5=BE=80=E8=BF=94=E6=96=AD?= =?UTF-8?q?=E8=A8=80=EF=BC=88M61=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/runtime/memory/vector/pg_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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]) + } }