From dd65fbcba0ee14f48045dbd9912a91da6d62f662 Mon Sep 17 00:00:00 2001 From: viettranx Date: Sat, 11 Apr 2026 12:04:38 +0700 Subject: [PATCH] test(integration): fix pre-existing bugs + post-Phase-4 contract update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three fixes required to run the integration suite after Phase 4: 1. v3_vault_store_test.go makeVaultDoc: AgentID is *string (nullable), not string — was a pre-existing type error from v3 commit 8f56ddaa that blocked the test binary build. Pass &agentID. 2. vault_classify_test.go imports: remove unused `store/pg` import — pre-existing from v3 commit 4b7a2e6e. 3. TestVaultClassify_DeleteDocLinksByTypes_MultipleTypes: fix off-by-one in target-doc loop. Pre-existing runtime panic from v3 commit — loop created 7 targets but linkTypes slice has 8 entries, accessing docs[8] on a len-8 slice. Changed loop to `range 8`. 4. TestVaultClassify_DeleteDocLinksByTypes_NonExistentDoc: swap "fake-doc-id-12345" placeholder for a well-formed but unused UUID. Post-Phase-4, parseUUID rejects bare strings at the caller boundary; the "non-existent = no-op" contract requires a syntactically valid UUID. Per Q7 documented contract change. Phase 4 Step 4g integration gate. --- tests/integration/v3_vault_store_test.go | 2 +- tests/integration/vault_classify_test.go | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/integration/v3_vault_store_test.go b/tests/integration/v3_vault_store_test.go index 7b36b6ba..4571f2dc 100644 --- a/tests/integration/v3_vault_store_test.go +++ b/tests/integration/v3_vault_store_test.go @@ -21,7 +21,7 @@ func newVaultStore(db *sql.DB) *pg.PGVaultStore { func makeVaultDoc(tenantID, agentID, path, title string) *store.VaultDocument { return &store.VaultDocument{ TenantID: tenantID, - AgentID: agentID, + AgentID: &agentID, Scope: "personal", Path: path, Title: title, diff --git a/tests/integration/vault_classify_test.go b/tests/integration/vault_classify_test.go index f6d0a5a5..ea234f55 100644 --- a/tests/integration/vault_classify_test.go +++ b/tests/integration/vault_classify_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/nextlevelbuilder/goclaw/internal/store" - "github.com/nextlevelbuilder/goclaw/internal/store/pg" ) func TestVaultClassify_DeleteDocLinksByTypes_SingleType(t *testing.T) { @@ -97,12 +96,12 @@ func TestVaultClassify_DeleteDocLinksByTypes_MultipleTypes(t *testing.T) { tid := tenantID.String() aid := agentID.String() - // Create source doc and 4 target docs (for 6 different link types + semantic) + // Create source doc and 8 target docs (one per link type: 6 classify + semantic + wikilink). docSource := makeVaultDoc(tid, aid, "source.md", "Source") docs := make([]*store.VaultDocument, 0) docs = append(docs, docSource) - for i := 0; i < 7; i++ { + for i := range 8 { doc := makeVaultDoc(tid, aid, "classify/target-"+string(rune('a'+i))+".md", "Target "+string(rune('A'+i))) if err := vs.UpsertDocument(ctx, doc); err != nil { t.Fatalf("UpsertDocument target %d: %v", i, err) @@ -443,8 +442,11 @@ func TestVaultClassify_DeleteDocLinksByTypes_NonExistentDoc(t *testing.T) { tid := tenantID.String() - // Try to delete links from non-existent doc — should succeed (no-op) - fakeDocID := "fake-doc-id-12345" + // Use a well-formed but non-existent UUID — post-Phase-4 parseUUID rejects + // bare strings like "fake-doc-id-12345" at the caller boundary, so the + // "non-existent doc = no-op" contract requires a syntactically valid UUID + // that just happens to not exist in the DB. + fakeDocID := "00000000-0000-4000-8000-000000000dea" if err := vs.DeleteDocLinksByTypes(ctx, tid, fakeDocID, []string{"reference"}); err != nil { t.Fatalf("DeleteDocLinksByTypes on non-existent doc: %v", err) }