Skip to content

Commit

Permalink
Port test runner over to Kaocha
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiago Luchini committed Nov 26, 2018
1 parent 737c45d commit 9fecbfa
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 35 deletions.
5 changes: 2 additions & 3 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
{:test
{:extra-paths ["test"]
:extra-deps
{com.cognitect/test-runner {:git/url "https://github.com/cognitect-labs/test-runner.git"
:sha "5fb4fc46ad0bf2e0ce45eba5b9117a2e89166479"}}
:main-opts ["-m" "cognitect.test-runner"]}
{lambdaisland/kaocha {:mvn/version "0.0-266"}}
:main-opts ["-m" "kaocha.runner"]}

:fig {:extra-deps
{org.clojure/clojurescript {:mvn/version "1.10.339"}
Expand Down
8 changes: 4 additions & 4 deletions src/hodur_engine/utils.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@
:type->param-return :ltr
:interface->type :ltr
:union->type :ltr}})
opts)])
(-> conn
(dependency-map opts')
kahn-sort)))
opts)]
(-> conn
(dependency-map opts')
kahn-sort))))

#_(let [meta-db (init-schema
'[A
Expand Down
58 changes: 33 additions & 25 deletions test/hodur_engine/test_core.clj → test/hodur_engine/core_test.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns hodur-engine.test-core
(ns hodur-engine.core-test
(:require [camel-snake-kebab.core :refer [->camelCaseKeyword
->PascalCaseKeyword
->kebab-case-keyword
Expand All @@ -23,7 +23,7 @@

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(deftest test-simple-type-and-field
(deftest simple-type-and-field
(let [res (init-and-pull
'[PersonEntity [the-name]]
'[* {:field/_parent [*]}]
Expand All @@ -49,7 +49,7 @@
(is (= :the_name
(-> res :field/_parent first :field/snake_case_name)))))

(deftest test-simple-type-field-param
(deftest simple-type-field-param
(let [res (init-and-pull
'[PersonEntity
[the-name [arg_a arg_b]]]
Expand All @@ -68,7 +68,7 @@
(is (= :arg_a
(-> res :field/_parent first :param/_parent first :param/snake_case_name)))))

(deftest test-primitive-types
(deftest primitive-types
(let [res (init-and-query
'[Person
[^String name
Expand Down Expand Up @@ -106,7 +106,7 @@
snake_case_name))
(is (= :primitive nature))))))

(deftest test-implements
(deftest implements
;; Only one implement
(let [res (init-and-pull
'[Animal [species]
Expand Down Expand Up @@ -134,7 +134,7 @@
(filter #(= (:type/name %) "Herbivore"))
first))))))

(deftest test-type-relationships-on-field
(deftest type-relationships-on-field
;; Only one
(let [res (init-and-pull
'[Person
Expand Down Expand Up @@ -167,7 +167,7 @@
(is (= '[0 n]
(-> field :field/cardinality)))))

(deftest test-type-relationships-on-params
(deftest type-relationships-on-params
(let [res (init-and-query
'[Location
[^Float
Expand Down Expand Up @@ -234,7 +234,7 @@
(is (= true
(-> name-param :param/optional)))))

(deftest test-type-markers
(deftest type-markers
(let [res (init-and-query
'[^:interface InterfaceType []
^:enum EnumType []
Expand Down Expand Up @@ -271,7 +271,7 @@
(is (= "This is the deprecation note"
(-> doc :type/deprecation)))))

(deftest test-field-markers
(deftest field-markers
(let [res (init-and-pull
'[Type
[^{:doc "This is the doc"
Expand Down Expand Up @@ -300,7 +300,7 @@
(is (= [4]
(-> exactly-four :field/cardinality)))))

(deftest test-namespaced-markers
(deftest namespaced-markers
(let [res (init-and-pull
'[^{:lacinia/identifier "query"
:graphviz/color "aquamarine"}
Expand Down Expand Up @@ -358,12 +358,12 @@
(is (= "decimal-param"
(-> res :param/name)))))

(deftest test-multiple-schemas
(deftest multiple-schemas
(let [c1 (engine/init-schema '[A [] B [] C [] D []])
c2 (engine/init-schema '[A [] B []] '[C [] D []])]
(is (= @c1 @c2))))

(deftest test-multiple-schemas-different-defaults
(deftest multiple-schemas-different-defaults
(let [c (engine/init-schema
'[^{:datomic/tag true}
default
Expand Down Expand Up @@ -406,7 +406,7 @@
(:param/name d)
(is (= "p2" (:param/name d)))))))

(deftest test-tagging-recursively
(deftest tagging-recursively
(let [c (engine/init-schema
'[^{:datomic/tag-recursive true}
A [af [afp]]
Expand Down Expand Up @@ -456,7 +456,7 @@
(:param/name d)
(is (= "cfp" (:param/name d)))))))

(deftest test-tagging-recursively-with-finer-control
(deftest tagging-recursively-with-finer-control
(let [c (engine/init-schema
'[^{:datomic/tag-recursive {:only [af1 af3 af3p]}}
A [af1 [af1p]
Expand Down Expand Up @@ -494,7 +494,7 @@
(:param/name d)
(is (= "bf1p" (:param/name d)))))))

(deftest test-tagging-recursively-with-finer-control-and-defaults
(deftest tagging-recursively-with-finer-control-and-defaults
(let [c (engine/init-schema
'[^{:graphviz/tag true}
default
Expand Down Expand Up @@ -525,7 +525,7 @@
(is (= 3 (count graphviz-datomic)))
(is (= 4 (count graphviz-sql)))))

(deftest test-tagging-with-override-instructions
(deftest tagging-with-override-instructions
(let [c (engine/init-schema
'[^{:sql/tag true}
default
Expand Down Expand Up @@ -563,7 +563,7 @@
(is (or (= "cfp" (:param/name d))
(= "dfp" (:param/name d))))))))

(deftest test-path
(deftest path
(let [c (engine/init-path "test/schemas/basic")
datomic
(d/q '[:find [?e ...]
Expand Down Expand Up @@ -615,13 +615,21 @@
(is (= 1 (count interfaces)))
(is (= 1 (count unions)))))

(deftest test-multiple-path
(deftest multiple-path
(let [lacinia-c (engine/init-path "test/schemas/several/lacinia"
"test/schemas/several/shared")
datomic-c (engine/init-path "test/schemas/several/datomic"
"test/schemas/several/shared")]))

(deftest test-same-name-fields
"test/schemas/several/shared")]
(is (= 23 (count (d/q '[:find [?e ...]
:where
[?e :node/type]]
@lacinia-c))))
(is (= 25 (count (d/q '[:find [?e ...]
:where
[?e :node/type]]
@datomic-c))))))

(deftest same-name-fields
(let [c (engine/init-schema
'[^{:lacinia/tag true}
A
Expand Down Expand Up @@ -654,7 +662,7 @@
(is (= "String"
(-> lacinia first :field/type :type/name)))))

(deftest test-field-type-cardinality
(deftest field-type-cardinality
(are [cardinality schema]
(= cardinality
(-> (init-and-query
Expand Down Expand Up @@ -694,7 +702,7 @@
:cardinality 6}
friends]]))

(deftest test-param-type-cardinality
(deftest param-type-cardinality
(are [cardinality schema]
(= cardinality
(-> (init-and-query
Expand All @@ -720,7 +728,7 @@
;;6 => [6 6]
[6 6] '[A [f [^{:cardinality 6} p]]]))

(deftest test-node-types
(deftest node-types
(let [meta-db (engine/init-schema
'[A
[^String af1
Expand All @@ -747,7 +755,7 @@
5 :field
2 :param)))

(deftest ^:wip test-union-field-types
(deftest union-field-types
(let [union-fields
(init-and-query
'[A
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns hodur-engine.test-utils
(ns hodur-engine.utils-test
(:require [camel-snake-kebab.core :refer [->camelCaseKeyword
->PascalCaseKeyword
->kebab-case-keyword
Expand All @@ -8,7 +8,7 @@
[hodur-engine.core :as engine]
[hodur-engine.utils :as utils]))

(deftest ^:failing test-acyclical-topological-sort
(deftest ^:wip acyclical-topological-sort-test
(let [meta-db (engine/init-schema
'[A
[^String af1
Expand All @@ -26,4 +26,4 @@
(println sorted)
(clojure.pprint/pprint
(d/pull-many @meta-db '[:field/name :type/name :param/name] sorted))
))
(is (= 1 2))))
2 changes: 2 additions & 0 deletions tests.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#kaocha/v1
{:tests [{:test-paths ["test"]}]}

0 comments on commit 9fecbfa

Please sign in to comment.