From 516f03f510be8d83130defcb2550a2af24d895d6 Mon Sep 17 00:00:00 2001 From: Case Nelson <case@metabase.com> Date: Mon, 4 Nov 2024 15:42:51 -0700 Subject: [PATCH] fix: tests for clickhouse development (#49347) --- .clj-kondo/test/hooks/clojure/test_test.clj | 13 ++++++++----- test/metabase/api/pivots.clj | 4 +--- test/metabase/events/view_log_test.clj | 7 ++++++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.clj-kondo/test/hooks/clojure/test_test.clj b/.clj-kondo/test/hooks/clojure/test_test.clj index 19bf39b4621..bcd487a1c90 100644 --- a/.clj-kondo/test/hooks/clojure/test_test.clj +++ b/.clj-kondo/test/hooks/clojure/test_test.clj @@ -3,7 +3,6 @@ [clj-kondo.hooks-api :as api] [clj-kondo.impl.utils] [clojure.edn :as edn] - [clojure.java.io :as io] [clojure.test :refer :all] [hooks.clojure.test])) @@ -44,9 +43,13 @@ (testing "Make sure we keep hooks.clojure.test/driver-keywords up to date" (let [driver-keywords (-> (slurp ".clj-kondo/config.edn") edn/read-string - (get-in [:linters :metabase/disallow-hardcoded-driver-names-in-tests :drivers]))] - (doseq [^java.io.File file (.listFiles (io/file "modules/drivers")) - :when (.isDirectory file) - :let [driver (keyword (.getName file))]] + (get-in [:linters :metabase/disallow-hardcoded-driver-names-in-tests :drivers])) + driver-modules (->> (slurp "modules/drivers/deps.edn") + edn/read-string + :deps + vals + (keep (comp keyword :local/root)) + (into #{}))] + (doseq [driver driver-modules] (is (contains? driver-keywords driver) (format "hooks.clojure.test/driver-keywords should contain %s, please add it" driver)))))) diff --git a/test/metabase/api/pivots.clj b/test/metabase/api/pivots.clj index 359228bafda..5b2541e49ad 100644 --- a/test/metabase/api/pivots.clj +++ b/test/metabase/api/pivots.clj @@ -5,9 +5,7 @@ (defn applicable-drivers "Drivers that these pivot table tests should run on" [] - (disj (mt/normal-drivers-with-feature :expressions :left-join) - ;; mongodb doesn't support foreign keys required by this test - :mongo + (disj (mt/normal-drivers-with-feature :expressions :left-join :metadata/key-constraints) ;; Disable on Redshift due to OutOfMemory issue (see #18834) :redshift)) diff --git a/test/metabase/events/view_log_test.clj b/test/metabase/events/view_log_test.clj index 56448181b8d..a377b8e0e0c 100644 --- a/test/metabase/events/view_log_test.clj +++ b/test/metabase/events/view_log_test.clj @@ -61,7 +61,12 @@ (latest-view (mt/user->id :crowberto) (u/id coll)))))))) (deftest update-view-dashboard-timestamp-test - (let [now (t/offset-date-time) + ;; the DB might save `last_used_at` with a different level of precision than the JVM does, on some machines + ;; `offset-date-time` returns nanosecond precision (9 decimal places) but `last_viewed_at` is coming back with + ;; microsecond precision (6 decimal places). We don't care about such a small difference, just strip it off of the + ;; times we're comparing. + (let [now (-> (t/offset-date-time) + (.withNano 0)) one-hour-ago (t/minus now (t/hours 1)) two-hours-ago (t/minus now (t/hours 2))] (testing "update with multiple dashboards of the same ids will set timestamp to the latest" -- GitLab