Skip to content
Snippets Groups Projects
Commit c3fa2aa1 authored by Cam Saül's avatar Cam Saül
Browse files

Test fixes :wrench:

parent 4fc501e4
No related merge requests found
......@@ -216,8 +216,8 @@
[(db/entity->table-name Table) :target-table]
[:= :target-pk.table_id :target-table.id]]
:where [:and [:in :source-fk.id (set fk-field-ids)]
[:= :source-fk.table_id source-table-id]
[:= :source-fk.special_type "fk"]]})))
[:= :source-fk.table_id source-table-id]
[:= :source-fk.special_type "fk"]]})))
(defn- fk-field-ids->joined-tables
"Fetch info for PK/FK `Fields` for the JOIN-TABLES referenced in a Query."
......
......@@ -42,6 +42,7 @@
:id (id :venues)}
:filter {:filter-type :>
:field {:field-id (id :venues :price)
:fk-field-id nil
:field-name "PRICE"
:field-display-name "Price"
:base-type :IntegerField
......@@ -56,6 +57,7 @@
:parent nil}
:value {:value 1
:field {:field-id (id :venues :price)
:fk-field-id nil
:field-name "PRICE"
:field-display-name "Price"
:base-type :IntegerField
......@@ -99,28 +101,30 @@
:id (id :venues)}
:filter {:filter-type :=
:field {:field-id (id :categories :name)
:fk-field-id (id :venues :category_id)
:field-name "NAME"
:field-display-name "Name"
:base-type :TextField
:special-type :name
:visibility-type :normal
:table-id (id :categories)
:schema-name "PUBLIC"
:table-name "CATEGORIES"
:schema-name nil
:table-name "CATEGORIES__via__CATEGORY_ID"
:position nil
:description nil
:parent-id nil
:parent nil}
:value {:value "abc"
:field {:field-id (id :categories :name)
:fk-field-id (id :venues :category_id)
:field-name "NAME"
:field-display-name "Name"
:base-type :TextField
:special-type :name
:visibility-type :normal
:table-id (id :categories)
:schema-name "PUBLIC"
:table-name "CATEGORIES"
:schema-name nil
:table-name "CATEGORIES__via__CATEGORY_ID"
:position nil
:description nil
:parent-id nil
......@@ -131,7 +135,8 @@
:field-name "ID"}
:table-id (id :categories)
:table-name "CATEGORIES"
:schema "PUBLIC"}]}
:schema "PUBLIC"
:join-alias "CATEGORIES__via__CATEGORY_ID"}]}
:fk-field-ids #{(id :venues :category_id)}
:table-ids #{(id :categories)}}]
(let [expanded-form (ql/expand (wrap-inner-query (query venues
......@@ -163,14 +168,15 @@
:id (id :checkins)}
:filter {:filter-type :>
:field {:field {:field-id (id :users :last_login)
:fk-field-id (id :checkins :user_id)
:field-name "LAST_LOGIN"
:field-display-name "Last Login"
:base-type :DateTimeField
:special-type nil
:visibility-type :normal
:table-id (id :users)
:schema-name "PUBLIC"
:table-name "USERS"
:schema-name nil
:table-name "USERS__via__USER_ID"
:position nil
:description nil
:parent-id nil
......@@ -178,14 +184,15 @@
:unit :year}
:value {:value (u/->Timestamp "1980-01-01")
:field {:field {:field-id (id :users :last_login)
:fk-field-id (id :checkins :user_id)
:field-name "LAST_LOGIN"
:field-display-name "Last Login"
:base-type :DateTimeField
:special-type nil
:visibility-type :normal
:table-id (id :users)
:schema-name "PUBLIC"
:table-name "USERS"
:schema-name nil
:table-name "USERS__via__USER_ID"
:position nil
:description nil
:parent-id nil
......@@ -197,7 +204,8 @@
:field-name "ID"}
:table-id (id :users)
:table-name "USERS"
:schema "PUBLIC"}]}
:schema "PUBLIC"
:join-alias "USERS__via__USER_ID"}]}
:fk-field-ids #{(id :checkins :user_id)}
:table-ids #{(id :users)}}]
(let [expanded-form (ql/expand (wrap-inner-query (query checkins
......@@ -238,8 +246,9 @@
:visibility-type :normal
:position nil
:field-id (id :venues :price)
:table-name "VENUES"
:schema-name "PUBLIC"}}
:fk-field-id (id :checkins :venue_id)
:table-name "VENUES__via__VENUE_ID"
:schema-name nil}}
:breakout [{:field {:description nil
:base-type :DateField
:parent nil
......@@ -251,6 +260,7 @@
:visibility-type :normal
:position nil
:field-id (id :checkins :date)
:fk-field-id nil
:table-name "CHECKINS"
:schema-name "PUBLIC"}
:unit :day-of-week}]
......@@ -260,7 +270,8 @@
:field-name "ID"}
:table-id (id :venues)
:table-name "VENUES"
:schema "PUBLIC"}]}
:schema "PUBLIC"
:join-alias "VENUES__via__VENUE_ID"}]}
:fk-field-ids #{(id :checkins :venue_id)}
:table-ids #{(id :venues) (id :checkins)}}]
(let [expanded-form (ql/expand (wrap-inner-query (query checkins
......
......@@ -24,11 +24,6 @@
(def ^:private ^:const timeseries-engines #{:druid})
(def ^:private ^:const non-timeseries-engines (set/difference datasets/all-valid-engines timeseries-engines))
;; Make sure the driver test extension namespaces are loaded. This is needed because otherwise `lein test metabase.query-processor-test` won't work
(doseq [engine non-timeseries-engines
:let [driver-test-ns (symbol (str "metabase.test.data." (name engine)))]]
(require driver-test-ns :reload))
(defn- engines-that-support [feature]
(set (for [engine non-timeseries-engines
:when (contains? (driver/features (driver/engine->driver engine)) feature)]
......
......@@ -4,7 +4,6 @@
[clojure.java.io :as io]
[clojure.set :as set]
[clojure.tools.logging :as log]
[colorize.core :as color]
[expectations :refer :all]
(metabase [core :as core]
[db :as db]
......@@ -67,8 +66,7 @@
;; # ------------------------------ FUNCTIONS THAT GET RUN ON TEST SUITE START / STOP ------------------------------
;; this is a little odd, but our normal `test-startup` function won't work for loading the drivers because
;; they need to be available at evaluation time for some of the unit tests work work properly, so we put this here
;; `test-startup` function won't work for loading the drivers because they need to be available at evaluation time for some of the unit tests work work properly
(driver/find-and-load-drivers!)
(defn test-startup
......@@ -83,6 +81,14 @@
(db/setup-db :auto-migrate true)
(setting/set :site-name "Metabase Test")
(core/initialization-complete!)
;; make sure the driver test extensions are loaded before running the tests. :reload them because otherwise we get wacky 'method in protocol not implemented' errors
;; when running tests against an individual namespace
(doseq [engine (keys (driver/available-drivers))
:let [driver-test-ns (symbol (str "metabase.test.data." (name engine)))]]
(u/ignore-exceptions
(require driver-test-ns :reload)))
;; If test setup fails exit right away
(catch Throwable e
(log/error (u/format-color 'red "Test setup failed: %s\n%s" e (u/pprint-to-str (vec (.getStackTrace e)))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment