Skip to content

Commit 19f730d

Browse files
committed
update mock/test for lsd_vectorstores_handler_test.go
1 parent 65d2156 commit 19f730d

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

packages/gen-ai/bff/internal/api/lsd_vectorstores_handler_test.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,20 @@ var _ = Describe("LlamaStackListVectorStoresHandler", func() {
6868
vectorStores := response.Data.([]interface{})
6969
assert.Len(t, vectorStores, 3)
7070

71-
// Find the auto-provisioned user store by its 32-char hashed username name
72-
var userStore map[string]interface{}
73-
for _, vs := range vectorStores {
74-
store := vs.(map[string]interface{})
75-
if name, ok := store["name"].(string); ok && len(name) == 32 {
71+
// Find the auto-provisioned user store by contract metadata marker
72+
var userStore map[string]interface{}
73+
for _, vs := range vectorStores {
74+
store := vs.(map[string]interface{})
75+
metadata, ok := store["metadata"].(map[string]interface{})
76+
if !ok {
77+
continue
78+
}
79+
if createdBy, ok := metadata["created_by"].(string); ok && createdBy == "auto-provisioning" {
7680
userStore = store
7781
break
7882
}
79-
}
80-
require.NotNil(t, userStore, "expected auto-provisioned user store with 32-char hashed name")
83+
}
84+
require.NotNil(t, userStore, "expected auto-provisioned user store")
8185
assert.NotEmpty(t, userStore["id"])
8286
assert.Contains(t, []string{"completed", "in_progress"}, userStore["status"])
8387
})

packages/gen-ai/bff/internal/integrations/llamastack/lsmocks/llamastack_client_mock.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ func (m *MockLlamaStackClient) CreateVectorStore(ctx context.Context, params lla
129129
}
130130

131131
mockID := "vs_mock_new123"
132+
metadata := map[string]string{
133+
"provider_id": "milvus",
134+
"provider_vector_db_id": mockID,
135+
}
136+
for k, v := range params.Metadata {
137+
metadata[k] = v
138+
}
132139
return &openai.VectorStore{
133140
ID: mockID,
134141
Object: "vector_store",
@@ -144,10 +151,7 @@ func (m *MockLlamaStackClient) CreateVectorStore(ctx context.Context, params lla
144151
},
145152
Status: "completed",
146153
LastActiveAt: 1755721097,
147-
Metadata: map[string]string{
148-
"provider_id": "milvus",
149-
"provider_vector_db_id": mockID,
150-
},
154+
Metadata: metadata,
151155
ExpiresAfter: openai.VectorStoreExpiresAfter{
152156
Anchor: "last_active_at",
153157
Days: 0,

0 commit comments

Comments
 (0)