mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-25 18:03:29 +08:00
Go: add context (#17314)
### Summary As title. --------- Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -20,12 +20,13 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"ragflow/internal/common"
|
||||
"ragflow/internal/engine"
|
||||
"ragflow/internal/engine/types"
|
||||
@@ -131,12 +132,12 @@ func (m *mockRetrievalService) Retrieval(ctx context.Context, req *nlp.Retrieval
|
||||
|
||||
type mockDocDAO struct {
|
||||
DocumentDAOIface
|
||||
getByIDsFn func(ids []string) ([]*entity.Document, error)
|
||||
getByIDsFn func(ctx context.Context, db *gorm.DB, ids []string) ([]*entity.Document, error)
|
||||
}
|
||||
|
||||
func (m *mockDocDAO) GetByIDs(ids []string) ([]*entity.Document, error) {
|
||||
func (m *mockDocDAO) GetByIDs(ctx context.Context, db *gorm.DB, ids []string) ([]*entity.Document, error) {
|
||||
if m.getByIDsFn != nil {
|
||||
return m.getByIDsFn(ids)
|
||||
return m.getByIDsFn(ctx, db, ids)
|
||||
}
|
||||
return []*entity.Document{
|
||||
{ID: "doc1", Name: strPtr("Test Doc")},
|
||||
@@ -382,7 +383,7 @@ func TestDifyRetrieval_KBDBError(t *testing.T) {
|
||||
func TestDifyRetrieval_DocLoadError(t *testing.T) {
|
||||
h, r := setupDifyTest("user1")
|
||||
h.docDAO = &mockDocDAO{
|
||||
getByIDsFn: func(ids []string) ([]*entity.Document, error) {
|
||||
getByIDsFn: func(ctx context.Context, db *gorm.DB, ids []string) ([]*entity.Document, error) {
|
||||
return nil, errors.New("db unavailable")
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user