The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
flake: fix temporal pollution (#68745)
John Swanson16e013a90d72
diff --git a/src/metabase/testing_api/api.clj b/src/metabase/testing_api/api.cljindex ef959957086..bf66092104a 100644--- a/src/metabase/testing_api/api.clj+++ b/src/metabase/testing_api/api.clj@@ -130,6 +130,8 @@"Restore a database snapshot for testing purposes."[{snapshot-name :name} :- [:map[:name ms/NonBlankString]]]+ ;; reset the system clock, in case `/set-time` was called without cleanup+ (alter-var-root #'java-time.clock/*clock* (constantly nil))(.clear ^Queue @#'search.ingestion/queue)(restore-snapshot! snapshot-name)(search/reindex! {:async? false})diff --git a/test/metabase/testing_api/api_test.clj b/test/metabase/testing_api/api_test.cljindex 78d0e658587..8643f414459 100644--- a/test/metabase/testing_api/api_test.clj+++ b/test/metabase/testing_api/api_test.clj@@ -42,6 +42,20 @@(is (= nil(mt/user-http-request :rasta :post 204 (format "testing/restore/%s" snapshot-name))))(finally+ (.delete (io/file (#'testing/snapshot-path-for-name snapshot-name))))))))+ (when (= (mdb/db-type) :h2)+ (testing "Restore should reset the java-time clock"+ (let [snapshot-name (munge (u/qualified-name ::test-snapshot))]+ (try+ (mt/user-http-request :rasta :post 204 (format "testing/snapshot/%s" snapshot-name))+ ;; Set the clock to a fixed time+ (mt/user-http-request :rasta :post 200 "testing/set-time" {:time "2024-01-01T00:00:00Z"})+ (is (some? java-time.clock/*clock*) "Clock should be set before restore")+ ;; Restore should reset the clock+ (mt/user-http-request :rasta :post 204 (format "testing/restore/%s" snapshot-name))+ (is (nil? java-time.clock/*clock*) "Clock should be reset after restore")+ (finally+ (alter-var-root #'java-time.clock/*clock* (constantly nil))(.delete (io/file (#'testing/snapshot-path-for-name snapshot-name)))))))))(deftest snapshot-restore-works-with-views