Skip to content

Commit

Permalink
Add Test Runner and fix metabase.driver.teradata-test
Browse files Browse the repository at this point in the history
  • Loading branch information
taabrcr authored and Cristian Bressi committed Jul 5, 2022
1 parent b116f06 commit 2426510
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 8 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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$"]
```
7 changes: 7 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand All @@ -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}
}
}
22 changes: 14 additions & 8 deletions test/metabase/driver/teradata_test.clj
Original file line number Diff line number Diff line change
@@ -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"})))
(defexpect db-test
(expect
hardcoded
result))

0 comments on commit 2426510

Please sign in to comment.