From bc0585f77239ca98c56a9b081135999858c28231 Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Sun, 14 Mar 2021 16:54:23 +0100 Subject: [PATCH] refactor system test to use controller functions --- src/wanijo/schema/forms.clj | 2 +- test/wanijo/infra/system_test.clj | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/wanijo/schema/forms.clj b/src/wanijo/schema/forms.clj index 67c14fc..84ccd11 100644 --- a/src/wanijo/schema/forms.clj +++ b/src/wanijo/schema/forms.clj @@ -36,7 +36,7 @@ :required false :widget :checkbox :from-req #(if (some? %) 1 0)} - :uuid {:widget :hidden}} + :uuid {:widget :hidden}} :form-specs [::unique-attr-name-per-schema]}) (defn assign-form [users] diff --git a/test/wanijo/infra/system_test.clj b/test/wanijo/infra/system_test.clj index 0790a2c..a4c1c9e 100644 --- a/test/wanijo/infra/system_test.clj +++ b/test/wanijo/infra/system_test.clj @@ -3,14 +3,14 @@ [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])) + [wanijo.schema.routes :as schema-routes] + [wanijo.attribute.routes :as attr-routes])) (defn single-result [cypher extractor] (extractor - (first - (neo4j/exec-query! - (drv/create-query cypher) {})))) + (first + (neo4j/exec-query! + (drv/create-query cypher) {})))) (deftest allround-system-test (repl/setup-in-memory!) @@ -19,7 +19,8 @@ :u)) (testing "create schema" - (db-schema/create-new! "test-schema" (:uuid user)) + (schema-routes/new! {:params {:name "test-schema"} + :session {:uuid (:uuid user)}}) (def schema (single-result "MATCH (s:schema) RETURN s LIMIT 1" :s)) (is (= "test-schema" (:name schema))) @@ -29,15 +30,15 @@ (is (not= nil (:created_at schema)))) (testing "create attribute" - (db-attr/create-new! {:type "text" - :name "test-attr" - :required 1} - (:uuid schema) - (:uuid user)) + (attr-routes/new! {:params {:schema (:uuid schema) + :name "test-attr" + :type "string" + :required "1"} + :session {:uuid (:uuid user)}}) (def attr (single-result "MATCH (a:attribute) RETURN a" :a)) - (is (= "text") (:type attr)) - (is (= "test-attr") (:name attr)) + (is (= "string" (:type attr))) + (is (= "test-attr" (:name attr))) (is (= 1 (:required attr))) (is (= (:uuid user) (single-result "MATCH (a:attribute)-[:created_by]->(u:user)