Files
ragflow/internal/parser/parser/pdf_parser_nocgo_test.go
Jack 902d05b22b feat: parser component param check and family mapping fixes (#17312)
## Summary

Adds construction-time parameter validation to the ingestion
`ParserComponent` (mirroring the applicable subset of Python
`ParserParam.check()`), fixes a family-mapping mismatch that silently
skipped `output_format` validation and setup configuration for
image/audio files, and aligns the no-CGO parser stubs with the CGO
variants by threading `context.Context` through `ParseWithResult`.
2026-07-23 22:06:22 +08:00

34 lines
795 B
Go

//go:build !cgo
package parser
import (
"context"
"errors"
"testing"
)
func TestPDFParser_ParseWithResult_NoCGO(t *testing.T) {
ctx := context.Background()
pdf := NewPDFParser()
empty := pdf.ParseWithResult(ctx, "empty.pdf", nil)
if empty.Err != nil {
t.Fatalf("empty input: want nil err, got %v", empty.Err)
}
if empty.OutputFormat != "json" {
t.Fatalf("empty input OutputFormat = %q, want json", empty.OutputFormat)
}
if len(empty.JSON) != 1 {
t.Fatalf("empty input JSON len = %d, want 1", len(empty.JSON))
}
res := pdf.ParseWithResult(ctx, "a.pdf", []byte("%PDF-1.4"))
if res.Err == nil {
t.Fatal("want ErrPDFEngineUnavailable, got nil")
}
if !errors.Is(res.Err, ErrPDFEngineUnavailable) {
t.Fatalf("err = %v, want wraps ErrPDFEngineUnavailable", res.Err)
}
}