                    [:certname       "foo.local"]]     [1]]
                  [[[:certname       "foo.local"]
                    [:resource-type  "Notify"]]        [1 2 3]]]]
-          (let [equality-fn (fn [m [k v]] (= v (m k)))
-                expected    (expected-resource-events
+          (let [expected    (expected-resource-events
                               (utils/select-values basic-events matches)
                               report-hash)
                 term-fn     (fn [[field value]] ["=" (name field) value])
                 query       (vec (cons "and" (map term-fn terms)))
                 actual      (resource-events-query-result query)]
             (is (= actual expected)
+              (format "Results didn't match for query '%s'" query)))))
+
+      (testing "nested compound queries"
+        (doseq [[query matches]
+                [[["and"
+                    ["or"
+                      ["=" "resource-title" "hi"]
+                      ["=" "resource-title" "notify, yo"]]
+                    ["=" "status" "success"]]               [1]]
+                 [["or"
+                    ["and"
+                      ["=" "resource-title" "hi"]
+                      ["=" "status" "success"]]
+                    ["and"
+                      ["=" "resource-type" "Notify"]
+                      ["=" "property" "message"]]]          [1 2]]]]
+          (let [expected  (expected-resource-events
+                            (utils/select-values basic-events matches)
+                            report-hash)
+                actual    (resource-events-query-result query)]
+            (is (= actual expected)
+              (format "Results didn't match for query '%s'" query)))))
+
+      (testing "compound queries with both equality and inequality"
+        (doseq [[query matches]
+                [[["and"
+                    ["=" "status" "success"]
+                    ["<" "timestamp" "2011-01-01T12:00:02-03:00"]]  [1]]
+                 [["or"
+                    ["=" "status" "skipped"]
+                    ["<" "timestamp" "2011-01-01T12:00:02-03:00"]]  [1 3]]]]
+          (let [expected  (expected-resource-events
+                            (utils/select-values basic-events matches)
+                            report-hash)
+                actual    (resource-events-query-result query)]
+            (is (= actual expected)
               (format "Results didn't match for query '%s'" query)))))))
 
 
 
 
-

            (is (= actual expected)
              (format "Results didn't match for query '%s'" query))))))

    (testing "compound queries"
      (testing "'or' equality queries"
        (doseq [[terms matches]

                   [[[:new-value      "notify, yo"]
                     [:resource-title "notify, yar"]
                     [:resource-title "hi"]]            [1 2 3]]]]
          (let [expected    (expected-resource-events
                              (utils/select-values basic-events matches)
                              report-hash)
                term-fn     (fn [[field value]] ["=" (name field) value])
