Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add a test that demonstrates how unique relationships can be created

References #22.
  • Loading branch information...
commit 473be6b672525a7a24dab2c07181e826c713bcce 1 parent 2063e83
Michael Klishin authored
16 test/clojurewerkz/neocons/rest/test/mutating_cypher_test.clj
@@ -42,7 +42,21 @@
42 42 (let [n1 (nodes/create)
43 43 n2 (nodes/create)
44 44 [{r "r"}] (cy/tquery "START n1 = node({id1}), n2 = node({id2}) CREATE n1-[r:knows]->n2 RETURN r" {:id1 (:id n1)
45   - :id2 (:id n2)})]
  45 + :id2 (:id n2)})
  46 + xs (rel/all-outgoing-between n1 n2 ["knows"])]
  47 + (is (= 1 (count xs)))
  48 + (is (rel/starts-with? r (:id n1)))
  49 + (is (rel/ends-with? r (:id n2)))))
  50 +
  51 +(deftest ^{:cypher true} test-creating-a-relationship-between-nodes-if-it-does-not-exist
  52 + (let [n1 (nodes/create)
  53 + n2 (nodes/create)
  54 + [{r "r"}] (cy/tquery "START n1 = node({id1}), n2 = node({id2}) CREATE UNIQUE n1-[r:knows]->n2 RETURN r" {:id1 (:id n1)
  55 + :id2 (:id n2)})
  56 + _ (cy/tquery "START n1 = node({id1}), n2 = node({id2}) CREATE UNIQUE n1-[r:knows]->n2 RETURN r" {:id1 (:id n1)
  57 + :id2 (:id n2)})
  58 + xs (rel/all-outgoing-between n1 n2 ["knows"])]
  59 + (is (= 1 (count xs)))
46 60 (is (rel/starts-with? r (:id n1)))
47 61 (is (rel/ends-with? r (:id n2)))))
48 62

0 comments on commit 473be6b

Please sign in to comment.
Something went wrong with that request. Please try again.