add test that proves deleting edited instances breaks

master
Josha von Gizycki 2 years ago
parent 0d9e44b75d
commit 57412a5544

@ -8,7 +8,8 @@
[wanijo.attribute.routes :as attr-routes] [wanijo.attribute.routes :as attr-routes]
[wanijo.instance.routes :as inst-routes] [wanijo.instance.routes :as inst-routes]
[wanijo.instance.forms :as inst-forms] [wanijo.instance.forms :as inst-forms]
[wanijo.instance.db :as inst-db])) [wanijo.instance.db :as inst-db]
[clojure.pprint :as pp]))
(defn single-result (defn single-result
([cypher] ([cypher]
@ -123,11 +124,11 @@
(is (= (:uuid instance) (is (= (:uuid instance)
(single-result "MATCH (i:instance)-[:link]->(:instance) (single-result "MATCH (i:instance)-[:link]->(:instance)
RETURN i.uuid"))) RETURN i.uuid")))
(is (= (:uuid instance2) (is (= (:uuid instance2)
(single-result "MATCH (i:instance)<-[:link]-(:instance) (single-result "MATCH (i:instance)<-[:link]-(:instance)
RETURN i.uuid")))) RETURN i.uuid"))))
(testing "show instances" (testing "show instances"
(let [resp (inst-routes/route-show! (let [resp (inst-routes/route-show!
@ -143,6 +144,25 @@
(is (true? (string/includes? resp (:name instance)))) (is (true? (string/includes? resp (:name instance))))
(is (true? (string/includes? resp (:name schema)))))) (is (true? (string/includes? resp (:name schema))))))
(testing "modifying first instance"
(let [prop-uuid (single-result
(str
"MATCH (i:instance)<-[:of]-(p:property)
WHERE i.uuid = '" (:uuid instance) "'
RETURN p.uuid"))]
(inst-routes/route-edit!
(:uuid instance)
{:params {:name "new-instance-1"
(inst-forms/attr->field-id attr) "new-value"
(inst-forms/attr->uuid-field-id attr) prop-uuid}
:session {:uuid (:uuid user)}})
(is (= "new-value"
(single-result
(str
"MATCH (p:property)
WHERE p.uuid = '" prop-uuid "'
RETURN p.value"))))))
(testing "delete first instance" (testing "delete first instance"
(inst-routes/route-delete! (:uuid instance)) (inst-routes/route-delete! (:uuid instance))
(is (= 1 (single-result "MATCH (i:instance) RETURN COUNT(i)"))) (is (= 1 (single-result "MATCH (i:instance) RETURN COUNT(i)")))
@ -155,3 +175,6 @@
(is (= 0 (single-result "MATCH (i:instance) RETURN COUNT(i)"))) (is (= 0 (single-result "MATCH (i:instance) RETURN COUNT(i)")))
(is (= 0 (single-result "MATCH (p:property) RETURN COUNT(p)"))) (is (= 0 (single-result "MATCH (p:property) RETURN COUNT(p)")))
(is (= 1 (single-result "MATCH (s:schema) RETURN COUNT(s)"))))) (is (= 1 (single-result "MATCH (s:schema) RETURN COUNT(s)")))))
(comment
(allround-system-test))
Loading…
Cancel
Save