a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
29 lines
913 B
Go
29 lines
913 B
Go
package languages
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/zzet/gortex/internal/graph"
|
|
)
|
|
|
|
// TestPDFExtractorStream_FileNodeOnMalformed mirrors the byte-path behaviour:
|
|
// a malformed PDF read through the streaming route still yields exactly the
|
|
// KindFile node and never panics (the per-document recover holds).
|
|
func TestPDFExtractorStream_FileNodeOnMalformed(t *testing.T) {
|
|
e := NewPDFExtractor()
|
|
data := []byte("%PDF-1.4 not really a pdf")
|
|
var nodes []*graph.Node
|
|
require.NotPanics(t, func() {
|
|
err := e.ExtractStream("spec.pdf", bytes.NewReader(data), int64(len(data)),
|
|
func(n *graph.Node, _ []*graph.Edge) { nodes = append(nodes, n) })
|
|
require.NoError(t, err)
|
|
})
|
|
require.Len(t, nodes, 1)
|
|
require.Equal(t, graph.KindFile, nodes[0].Kind)
|
|
require.Equal(t, "pdf", nodes[0].Meta["asset_kind"])
|
|
require.Equal(t, len(data), nodes[0].Meta["size_bytes"])
|
|
}
|