Files
ragflow/internal/parser/parser/pdf_parser_nocgo_test.go
Jin Hai bdfc3ada41 Go: add context (#17314)
### Summary

As title.

---------

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
2026-07-24 16:47:12 +08:00

33 lines
785 B
Go

//go:build !cgo
package parser
import (
"context"
"errors"
"testing"
)
func TestPDFParser_ParseWithResult_NoCGO(t *testing.T) {
pdf := NewPDFParser()
ctx := t.Context()
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)
}
}