From bbbf86e31f484fe1194d019e91c44752b2a895d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cam=20Sa=C3=BCl?= <cammsaul@gmail.com> Date: Wed, 7 Jun 2017 17:15:59 -0700 Subject: [PATCH] Oh actually there were tests. Move them over :broken_heart: --- test/metabase/driver_test.clj | 19 ++++++++++++ .../middleware/annotate_and_sort_test.clj | 31 +------------------ 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/test/metabase/driver_test.clj b/test/metabase/driver_test.clj index c63925e7281..10c9774d482 100644 --- a/test/metabase/driver_test.clj +++ b/test/metabase/driver_test.clj @@ -36,3 +36,22 @@ (expect :type/* (driver/values->base-type [(Object.)])) + +;; Should work with initial nils even if sequence is lazy +(expect + [:type/Integer true] + (let [realized-lazy-seq? (atom false)] + [(driver/values->base-type (lazy-cat [nil nil nil] + (do (reset! realized-lazy-seq? true) + [4 5 6]))) + @realized-lazy-seq?])) + +;; but it should respect laziness and not keep scanning after it finds 100 values +(expect + [:type/Integer false] + (let [realized-lazy-seq? (atom false)] + [(driver/values->base-type (lazy-cat [1 2 3] + (repeat 1000 nil) + (do (reset! realized-lazy-seq? true) + [4 5 6]))) + @realized-lazy-seq?])) diff --git a/test/metabase/query_processor/middleware/annotate_and_sort_test.clj b/test/metabase/query_processor/middleware/annotate_and_sort_test.clj index a770dd0a0d1..0cb02e30d22 100644 --- a/test/metabase/query_processor/middleware/annotate_and_sort_test.clj +++ b/test/metabase/query_processor/middleware/annotate_and_sort_test.clj @@ -3,36 +3,7 @@ [metabase.test.util :as tu])) (tu/resolve-private-vars metabase.query-processor.middleware.annotate-and-sort - vals->base-type infer-column-types) - -;; tests for vals->base-type -(expect - :type/Integer - (vals->base-type [1 "A" "B"])) - -;; should work with some initial nils -(expect - :type/Text - (vals->base-type [nil nil "A"])) - -;; (even if sequence is lazy) -(expect - [:type/Integer true] - (let [realized-lazy-seq? (atom false)] - [(vals->base-type (lazy-cat [nil nil nil] - (do (reset! realized-lazy-seq? true) - [4 5 6]))) - @realized-lazy-seq?])) - -;; but it should respect laziness and not keep scanning after it finds the first non-`nil` value -(expect - [:type/Integer false] - (let [realized-lazy-seq? (atom false)] - [(vals->base-type (lazy-cat [1 2 3] - (do (reset! realized-lazy-seq? true) - [4 5 6]))) - @realized-lazy-seq?])) - + infer-column-types) ;; make sure that `infer-column-types` can still infer types even if the initial value(s) are `nil` (#4256) (expect -- GitLab