first part of an automated system test

alfred
Josha von Gizycki 4 years ago
parent 08fc2403a1
commit 4e3f0f86bd

@ -0,0 +1,47 @@
(ns wanijo.infra.system-test
(:require [clojure.test :refer :all]
[neo4j-clj.core :as drv]
[wanijo.infra.neo4j :as neo4j]
[wanijo.infra.repl :as repl]
[wanijo.schema.db :as db-schema]
[wanijo.attribute.db :as db-attr]))
(defn single-result [cypher extractor]
(extractor
(first
(neo4j/exec-query!
(drv/create-query cypher) {}))))
(deftest allround-system-test
(repl/setup-in-memory!)
(def user
(single-result "MATCH (u:user) RETURN u"
:u))
(testing "create schema"
(db-schema/create-new! "test-schema" (:uuid user))
(def schema
(single-result "MATCH (s:schema) RETURN s LIMIT 1" :s))
(is (= "test-schema" (:name schema)))
(is (= (:uuid user)
(single-result "MATCH (s:schema)-[:created_by]->(u:user)
RETURN u.uuid AS uuid" :uuid)))
(is (not= nil (:created_at schema))))
(testing "create attribute"
(db-attr/create-new! {:type "text"
:name "test-attr"
:required 1}
(:uuid schema)
(:uuid user))
(def attr
(single-result "MATCH (a:attribute) RETURN a" :a))
(is (= "text") (:type attr))
(is (= "test-attr") (:name attr))
(is (= 1 (:required attr)))
(is (= (:uuid user)
(single-result "MATCH (a:attribute)-[:created_by]->(u:user)
RETURN u.uuid AS uuid" :uuid)))
(is (= (:uuid schema)
(single-result "MATCH (a:attribute)-[:of]->(s:schema)
RETURN s.uuid AS uuid" :uuid)))))
Loading…
Cancel
Save