move to :pre, enable check-asserts

integration-tests
Josha von Gizycki 5 years ago
parent 4692b49d2e
commit 1bf2912ca9

@ -1,6 +1,5 @@
(ns wanijo.instance.domain (ns wanijo.instance.domain
(:require [clojure.spec.alpha :as spec] (:require [clojure.spec.alpha :as spec]
[clojure.spec.test.alpha :as spectest]
[wanijo.framework.neo4j :as neo4j] [wanijo.framework.neo4j :as neo4j]
[clojure.pprint :as pprint])) [clojure.pprint :as pprint]))
@ -109,7 +108,19 @@
ON MATCH SET p.updated_at = {now}, ON MATCH SET p.updated_at = {now},
p.value = {value}") p.value = {value}")
(spec/def ::now ::neo4j/date-str)
(spec/def ::prop-tuple-values
(spec/keys :req-un [::neo4j/uuid
::now
::value
::instance_uuid
::attribute_uuid]))
(spec/def ::prop-tuple
(spec/coll-of
(spec/tuple fn? ::prop-tuple-values)))
(defn instance->prop-tuples [instance] (defn instance->prop-tuples [instance]
{:post [(spec/assert ::prop-tuple %)]}
(map (fn [prop] (map (fn [prop]
(let [prop-uuid (:uuid prop) (let [prop-uuid (:uuid prop)
uuid (if (empty? prop-uuid) uuid (if (empty? prop-uuid)
@ -123,18 +134,6 @@
:attribute_uuid (-> prop :attribute :uuid)}])) :attribute_uuid (-> prop :attribute :uuid)}]))
(:properties instance))) (:properties instance)))
(spec/def ::prop-tuple-values
(spec/keys :req-un [::neo4j/uuid
::neo4j/date-str
::value
::instance_uuid
::attribute_uuid]))
(spec/def ::prop-tuple
(spec/tuple fn? ::prop-tuple-values))
(spec/fdef instance->prop-tuples
:ret (spec/coll-of ::prop-tuple))
(spectest/instrument `instance->prop-tuples)
(defn edit! [instance] (defn edit! [instance]
(let [prop-tuples (instance->prop-tuples instance)] (let [prop-tuples (instance->prop-tuples instance)]
(apply neo4j/exec-queries! (apply neo4j/exec-queries!

@ -3,6 +3,8 @@
[wanijo.handler :as wanijo]) [wanijo.handler :as wanijo])
(:gen-class)) (:gen-class))
(spec/check-asserts true)
(defonce server (atom nil)) (defonce server (atom nil))
(defn start-server! (defn start-server!

Loading…
Cancel
Save