test(ingest): cover insufficient-content gate; allow threshold override
Addresses two pre-merge review notes: 1. Extract the sentinel-returning threshold check from getSummary into a small package-private helper (checkSufficientSummaryContent) and add a unit test for it. The new test pins the behavior the caller in ProcessSummaryGeneration relies on: the sentinel is returned for empty / image-only / sub-threshold / scanned-PDF-without-OCR inputs, and nil is returned for legitimate short notes and scanned PDFs where VLM OCR succeeded. The downstream "errors.Is(err, errInsufficientSummaryContent) → SummaryStatusFailed + skip summary chunk" branch is mechanical (no branching beyond the errors.Is check); covering it end-to-end would require mocking KnowledgeRepository / ChunkRepository / chat.Chat, for which there is no precedent in this package. 2. Switch minTextContentRunes from const to var so tests can override the threshold and so future config plumbing can adjust it at runtime without a rebuild. The new test exercises the override.
This commit is contained in:
@@ -1225,7 +1225,10 @@ func appendUnique(arr types.StringArray, s string) types.StringArray {
|
||||
// The threshold is intentionally low: legitimate short documents (brief
|
||||
// memos, single-line notes) must still pass. The goal is only to catch
|
||||
// the empty-image-only case.
|
||||
const minTextContentRunes = 10
|
||||
//
|
||||
// Declared as a var (not const) so tests can override it and future config
|
||||
// plumbing can adjust it at runtime without a rebuild.
|
||||
var minTextContentRunes = 10
|
||||
|
||||
var (
|
||||
// Markdown image references like  — pure visual placeholders
|
||||
|
||||
Reference in New Issue
Block a user