From dd4120bb91ecf53f32f164a6e9b79ddce1adb42e Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Tue, 12 Nov 2019 16:19:01 +0000 Subject: [PATCH] Run `lein ancient` and updated dependencies. to_psql_tests do NOT yet pass (new file, never has passed) --- project.clj | 4 +-- src/adl/to_psql.clj | 2 +- test/adl/to_psql_test.clj | 73 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 test/adl/to_psql_test.clj diff --git a/project.clj b/project.clj index c20cfb3..e212a47 100644 --- a/project.clj +++ b/project.clj @@ -11,8 +11,8 @@ [environ "1.1.0"] [hiccup "1.0.5"] [org.clojure/clojure "1.8.0"] - [org.clojure/math.combinatorics "0.1.4"] - [org.clojure/tools.cli "0.3.7"]] + [org.clojure/math.combinatorics "0.1.6"] + [org.clojure/tools.cli "0.4.2"]] :aot [adl.main] diff --git a/src/adl/to_psql.clj b/src/adl/to_psql.clj index b3dd1f8..f913692 100644 --- a/src/adl/to_psql.clj +++ b/src/adl/to_psql.clj @@ -198,7 +198,7 @@ (if (and (= (:tag property) :property) - (not (#{"link"} (:type (:attrs property))))) + (not (#{"link" "list£"} (:type (:attrs property))))) (s/join " " (remove diff --git a/test/adl/to_psql_test.clj b/test/adl/to_psql_test.clj new file mode 100644 index 0000000..418d688 --- /dev/null +++ b/test/adl/to_psql_test.clj @@ -0,0 +1,73 @@ +(ns adl.to-psql-test + (:require [clojure.string :as s] + [clojure.test :refer :all] + [adl.to-psql :refer :all] + [adl-support.utils :refer :all])) + +(deftest create-table-test + (testing "Generation of table creation" + (let [application {:tag :application, + :attrs {:version "0.1.1", :name "test-app"}, + :content + [{:tag :entity, + :attrs {:name "address"}, + :content + [{:tag :key, + :attrs nil, + :content + [{:tag :property, + :attrs + {:immutable "true", + :required "true", + :distinct "system", + :type "integer", + :name "id"}, + :content + [{:tag :generator, :attrs {:action "native"}, :content nil}]} + {:tag :property, + :attrs + {:immutable "true", + :required "true", + :distinct "all", + :generator "assigned" + :type "string", + :size "12" + :name "postcode"}} + ]} + {:tag :property, + :attrs + {:distinct "user", :size "128", :type "string", :name "street"}, + :content nil} + {:tag :property, + :attrs {:size "64", :type "string", :name "town"}, + :content nil} + {:tag :property, + :attrs {:name "dwellings" :type "list" :entity "dwellings" :farkey "address_id"}} + ]} + {:tag :entity, + :attrs {:name "dwelling"}, + :content + [{:tag :key, + :attrs nil, + :content + [{:tag :property, + :attrs + {:immutable "true", + :required "true", + :distinct "system", + :type "integer", + :name "id"}, + :content + [{:tag :generator, :attrs {:action "native"}, :content nil}]}]} + {:tag :property + :attrs + {:name "address_id" :required "true" :type "entity" :entity "address" :farkey "id"}} + {:tag :property + :attrs + {:name "sub_address" :type "string" :size "32"}}]}]} + address-entity (child-with-tag application :entity #(= (:name %) "address")) + dwelling-entity (child-with-tag application :entity #(= (:name %) "dwelling")) + expected "" + actual (emit-table address-entity application "Test doc") + ] + (is (= actual expected)))))