diff options
Diffstat (limited to 'internal/cond/eval_test.go')
| -rw-r--r-- | internal/cond/eval_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/cond/eval_test.go b/internal/cond/eval_test.go index 8891de7..88612ac 100644 --- a/internal/cond/eval_test.go +++ b/internal/cond/eval_test.go @@ -226,3 +226,17 @@ func TestNegatedCombinatorReason(t *testing.T) { t.Errorf("negated leaf = %+v, want its own label unchanged: %q", r, "not matched") } } + +// TestEvalReportsUnreadableContent: Result.Unreadable says a content test +// was reached and could not read the file - what lets an exclude fail +// closed (review M11) - and stays false when evaluation never reached the +// content test. +func TestEvalReportsUnreadableContent(t *testing.T) { + f := &fake{name: "a.pdf", rawErr: errors.New("larger than max-read")} + if r := eval(t, `(and (type pdf) (content "x"))`, Options{}, f); r.Match || !r.Unreadable { + t.Errorf("reached: Match %v Unreadable %v; want false, true", r.Match, r.Unreadable) + } + if r := eval(t, `(or (name "^a") (content "x"))`, Options{}, f); !r.Match || r.Unreadable { + t.Errorf("not reached: Match %v Unreadable %v; want true, false", r.Match, r.Unreadable) + } +} |
