feat(tests): enhance vector store tests with fake Elasticsearch server and add user pinning methods to knowledge base repository

Introduced a new helper function to create a fake Elasticsearch server for testing, improving the reliability of connection probes in vector store tests. Additionally, added methods for setting and listing user-specific knowledge base pins in the knowledge base repository, aligning with recent user pinning features.

Refs: #1303
This commit is contained in:
wizardchen
2026-05-18 17:56:06 +08:00
committed by lyingbug
parent fc2d858222
commit bbcedbee63
2 changed files with 43 additions and 7 deletions
@@ -4,6 +4,7 @@ import (
"context"
stderrors "errors"
"testing"
"time"
"github.com/Tencent/WeKnora/internal/application/service/retriever"
apperrors "github.com/Tencent/WeKnora/internal/errors"
@@ -107,6 +108,12 @@ func (r *fakeKBRepo) TogglePinKnowledgeBase(_ context.Context, _ string, _ uint6
func (r *fakeKBRepo) CountByVectorStoreID(_ context.Context, _ *gorm.DB, _ uint64, _ string) (int64, error) {
return 0, nil
}
func (r *fakeKBRepo) SetUserKBPin(_ context.Context, _ uint64, _ string, _ string, _ bool) (*time.Time, error) {
return nil, nil
}
func (r *fakeKBRepo) ListUserKBPinIDs(_ context.Context, _ uint64, _ string) (map[string]time.Time, error) {
return map[string]time.Time{}, nil
}
// Force compile-time conformance check so any future interface change
// surfaces as a build error here rather than at usage site.