Files
wehub-resource-sync f36e2104d8
tests / ragflow_tests_infinity (push) Has been cancelled
tests / ragflow_tests_elasticsearch (push) Has been cancelled
sep-tests / ragflow_preflight (push) Has been cancelled
sep-tests / ragflow_tests_infinity (push) Has been cancelled
sep-tests / ragflow_tests_elasticsearch (push) Has been cancelled
tests / ragflow_preflight (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:16:49 +08:00

50 lines
1.3 KiB
Go

package pdf
import (
"context"
"image"
pdf "ragflow/internal/deepdoc/parser/pdf/type"
)
// MockDocAnalyzer returns predefined data for unit tests.
// Set an Err field to non-nil to exercise the corresponding error path.
type MockDocAnalyzer struct {
DLARegions []pdf.DLARegion
TSRCells []pdf.TSRCell
OCRBoxes []pdf.OCRBox
OCRTexts []pdf.OCRText
// Per-method error injection for testing failure paths.
DLAErr error
TSRErr error
OCRDetectErr error
OCRRecognizeErr error
Healthy bool
}
func (m *MockDocAnalyzer) DLA(_ context.Context, _ image.Image) ([]pdf.DLARegion, error) {
if m.DLAErr != nil {
return nil, m.DLAErr
}
return m.DLARegions, nil
}
func (m *MockDocAnalyzer) TSR(_ context.Context, _ image.Image) ([]pdf.TSRCell, error) {
if m.TSRErr != nil {
return nil, m.TSRErr
}
return m.TSRCells, nil
}
func (m *MockDocAnalyzer) OCRDetect(_ context.Context, _ image.Image) ([]pdf.OCRBox, error) {
if m.OCRDetectErr != nil {
return nil, m.OCRDetectErr
}
return m.OCRBoxes, nil
}
func (m *MockDocAnalyzer) OCRRecognize(_ context.Context, _ image.Image) ([]pdf.OCRText, error) {
if m.OCRRecognizeErr != nil {
return nil, m.OCRRecognizeErr
}
return m.OCRTexts, nil
}
func (m *MockDocAnalyzer) Health() bool { return m.Healthy }