aboutsummaryrefslogtreecommitdiff
path: root/internal/cond/eval_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cond/eval_test.go')
-rw-r--r--internal/cond/eval_test.go24
1 files changed, 20 insertions, 4 deletions
diff --git a/internal/cond/eval_test.go b/internal/cond/eval_test.go
index 7d796a1..9352b82 100644
--- a/internal/cond/eval_test.go
+++ b/internal/cond/eval_test.go
@@ -21,6 +21,7 @@ type fake struct {
size int64
age time.Duration
matched bool
+ matchedUnknown bool
dupOrig string
dupOK bool
contentCalls int
@@ -33,10 +34,10 @@ func (f *fake) Rel() string {
}
return f.name
}
-func (f *fake) Size() int64 { return f.size }
-func (f *fake) ModTime() time.Time { return now.Add(-f.age) }
-func (f *fake) Now() time.Time { return now }
-func (f *fake) Matched() bool { return f.matched }
+func (f *fake) Size() int64 { return f.size }
+func (f *fake) ModTime() time.Time { return now.Add(-f.age) }
+func (f *fake) Now() time.Time { return now }
+func (f *fake) Matched() (bool, bool) { return f.matched, f.matchedUnknown }
func (f *fake) ContentContains(opt Options, keywords []string) (int, error) {
f.contentCalls++
if f.rawErr != nil {
@@ -284,3 +285,18 @@ func TestUnreadableContentIsUnknown(t *testing.T) {
}
}
}
+
+// TestMatchedIsUnknownAfterAnUnknownRule: when no earlier rule matched but
+// one could not be decided, (matched) is unknown, so a later
+// (not (matched)) does not act on a file krino could not read (plan 11
+// review L6).
+func TestMatchedIsUnknownAfterAnUnknownRule(t *testing.T) {
+ f := &fake{name: "a.docx", matchedUnknown: true}
+ if r := eval(t, `(not (matched))`, Options{}, f); r.Match || !r.Unreadable {
+ t.Errorf("(not (matched)): Match %v Unreadable %v; want false, true", r.Match, r.Unreadable)
+ }
+ f = &fake{name: "a.docx", matched: true, matchedUnknown: true}
+ if r := eval(t, `(matched)`, Options{}, f); !r.Match {
+ t.Errorf("(matched) after a rule that did match: %+v, want true", r)
+ }
+}