From 24265105a0a989e3e06a8799e1ea8d0dbd9efe43 Mon Sep 17 00:00:00 2001 From: taabrcr Date: Tue, 5 Jul 2022 15:04:51 +0200 Subject: [PATCH] Add Test Runner and fix metabase.driver.teradata-test --- README.md | 32 ++++++++++++++++++++++++++ deps.edn | 7 ++++++ test/metabase/driver/teradata_test.clj | 22 +++++++++++------- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 62a698f..a480b40 100644 --- a/README.md +++ b/README.md @@ -67,3 +67,35 @@ You require metabase to be installed alongside of your project 2. `clojure -X:build :project-dir "\"$(pwd)\""` This will build a file called `target/teradata.metabase-driver.jar`; copy this to your Metabase `./plugins` directory. + + +## Tests + +Invoking the test-runner with `clojure -X` will call the test function with a map of arguments, +which can be supplied either in the alias (via `:exec-args`) or on the command-line, or both. + +Invoke it with: + +```bash +clj -X:test ...args... +``` + +This will scan your project's `test` directory for any tests defined +using `clojure.test` and run them. + +You may also supply any of the additional command line options: + +``` + :dirs - coll of directories containing tests, default= ["test"] + :nses - coll of namespace symbols to test + :patterns - coll of regex strings to match namespaces + :vars - coll of fully qualified symbols to run tests on + :includes - coll of test metadata keywords to include + :excludes - coll of test metadata keywords to exclude" +``` + +If neither :dirs or :nses is supplied, will use: + +``` + :patterns [".*-test$"] +``` \ No newline at end of file diff --git a/deps.edn b/deps.edn index a6d191d..815fbd1 100644 --- a/deps.edn +++ b/deps.edn @@ -8,6 +8,7 @@ :deps { org.clojure/clojure {:mvn/version "1.11.1"} + expectations/clojure-test {:mvn/version "1.2.1"} ; replace also the version in metabase-plugin.yaml metabase/metabase-core {:git/url "https://github.com/metabase/metabase.git" :git/tag "v0.43.0" :git/sha "ee686fcfe5"} metabase/build-drivers {:git/url "https://github.com/metabase/metabase.git" :git/tag "v0.43.0" :git/sha "ee686fcfe5" :deps/root "bin/build-drivers"} @@ -24,5 +25,11 @@ } ; We don't want to include metabase nor clojure in the uber jar :oss {:replace-deps {} } + + :test {:extra-paths ["test"] + :extra-deps {io.github.cognitect-labs/test-runner + {:git/tag "v0.5.1" :git/sha "dfb30dd"}} + :main-opts ["-m" "cognitect.test-runner"] + :exec-fn cognitect.test-runner.api/test} } } \ No newline at end of file diff --git a/test/metabase/driver/teradata_test.clj b/test/metabase/driver/teradata_test.clj index a019fd0..62379f5 100644 --- a/test/metabase/driver/teradata_test.clj +++ b/test/metabase/driver/teradata_test.clj @@ -1,12 +1,18 @@ (ns metabase.driver.teradata-test - (:require [expectations :refer :all] + (:require [expectations.clojure.test :refer [defexpect expect expecting]] [metabase.driver.sql-jdbc.connection :as sql-jdbc.conn])) +(def result + (sql-jdbc.conn/connection-details->spec :teradata {:host "localhost" + :additional-options "CONNECT_FAILURE_TTL=300,ERROR_QUERY_INTERVAL=300000,RECONNECT_INTERVAL=300,COP=OFF,REDRIVE=0"})) + +(def hardcoded + {:classname "com.teradata.jdbc.TeraDriver" + :subprotocol "teradata" + :subname "//localhost/CHARSET=UTF8,TMODE=ANSI,ENCRYPTDATA=ON,FINALIZE_AUTO_CLOSE=ON,LOB_SUPPORT=OFF,CONNECT_FAILURE_TTL=300,ERROR_QUERY_INTERVAL=300000,RECONNECT_INTERVAL=300,COP=OFF,REDRIVE=0"}) + ;; Check that additional JDBC options are handled correctly. This is comma separated for Teradata. -(expect - {:classname "com.teradata.jdbc.TeraDriver" - :subprotocol "teradata" - :subname "//localhost/CHARSET=UTF8,TMODE=ANSI,ENCRYPTDATA=ON,FINALIZE_AUTO_CLOSE=ON,LOB_SUPPORT=OFF,COP=OFF" - :delimiters "`"} - (-> (sql-jdbc.conn/connection-details->spec :teradata {:host "localhost" - :additional-options "COP=OFF"}))) \ No newline at end of file +(defexpect db-test + (expect + hardcoded + result)) \ No newline at end of file