Skip to content

Commit 68dca28

Browse files
author
Paula Gearon
committed
Added multi-property test for rules on extended data
1 parent 330a9f6 commit 68dca28

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

test/naga/test_rules.clj

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,20 @@
129129
(is (= 2 (count
130130
(filter (fn [[e a v]]
131131
(and (= e v) (nodes e) (= :db/ident a)))
132-
data))))))
132+
data)))))
133+
(let [rx [(r "multi-prop" [?z :first :a] [?z :second ?y] :- [?x :foo ?y])]
134+
ax [[:data :foo :bar] [:other :foo :baz]]
135+
program (r/create-program rx ax)
136+
[store results] (e/run {:type :memory} program)
137+
data' (store/resolve-pattern store '[?e ?a ?v])
138+
data (remove #(#{[:data :foo :bar] [:other :foo :baz]} %) data')
139+
nodes (set (map first data))]
140+
(is (= 6 (count data)))
141+
(is (= 2 (count nodes)))
142+
(is (= 2 (count (filter (fn [[e a v]] (and (nodes e) (= [:first :a] [a v]))) data))))
143+
(is (= 1 (count (filter (fn [[e a v]] (and (nodes e) (= [:second :bar] [a v]))) data))))
144+
(is (= 1 (count (filter (fn [[e a v]] (and (nodes e) (= [:second :baz] [a v]))) data))))
145+
(is (= 2 (count (filter (fn [[e a v]] (and (nodes e) (= e v) (= :db/ident a))) data))))))
133146

134147
;; todo blank-multi-prop
135148

0 commit comments

Comments
 (0)