From cde631310807d079889f7277e5754c9cb40ca853 Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Thu, 18 Mar 2021 17:10:22 +0100 Subject: [PATCH] add three more test cases to system test --- test/wanijo/infra/system_test.clj | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/test/wanijo/infra/system_test.clj b/test/wanijo/infra/system_test.clj index e90d048..0b54dae 100644 --- a/test/wanijo/infra/system_test.clj +++ b/test/wanijo/infra/system_test.clj @@ -1,6 +1,7 @@ (ns wanijo.infra.system-test (:require [clojure.test :refer :all] [neo4j-clj.core :as drv] + [clojure.string :as string] [wanijo.infra.neo4j :as neo4j] [wanijo.infra.repl :as repl] [wanijo.schema.routes :as schema-routes] @@ -126,4 +127,31 @@ (is (= (:uuid instance2) (single-result "MATCH (i:instance)<-[:link]-(:instance) - RETURN i.uuid"))))) + RETURN i.uuid")))) + + (testing "show instances" + (let [resp (inst-routes/route-show! + (:uuid instance) + {:session {:uuid (:uuid user)}})] + (is (true? (string? resp))) + (is (true? (string/includes? resp (:name instance)))) + (is (true? (string/includes? resp (:name schema))))) + (let [resp (inst-routes/route-show! + (:uuid instance2) + {:session {:uuid (:uuid user)}})] + (is (true? (string? resp))) + (is (true? (string/includes? resp (:name instance)))) + (is (true? (string/includes? resp (:name schema)))))) + + (testing "delete first instance" + (inst-routes/route-delete! (:uuid instance)) + (is (= 1 (single-result "MATCH (i:instance) RETURN COUNT(i)"))) + (is (= 1 (single-result "MATCH (p:property) RETURN COUNT(p)"))) + (is (= 1 (single-result "MATCH (s:schema) RETURN COUNT(s)"))) + (is (= 0 (single-result "MATCH ()-[l:link]-() RETURN COUNT(l)")))) + + (testing "delete second instance" + (inst-routes/route-delete! (:uuid instance2)) + (is (= 0 (single-result "MATCH (i:instance) RETURN COUNT(i)"))) + (is (= 0 (single-result "MATCH (p:property) RETURN COUNT(p)"))) + (is (= 1 (single-result "MATCH (s:schema) RETURN COUNT(s)")))))