Skip to content
Snippets Groups Projects
Commit 81f9aaf5 authored by Cam Saul's avatar Cam Saul
Browse files

final changes to make everything work

parent 5b2d0684
No related branches found
No related tags found
No related merge requests found
......@@ -154,8 +154,11 @@
:description nil})]))
(do
;; Delete all the randomly created Databases we've made so far
(cascade-delete Database :organization_id @org-id :id [not-in (set [@db-id
@mongo-test-data/mongo-test-db-id])])
(cascade-delete Database :organization_id @org-id :id [not-in (set (filter identity
[(datasets/when-testing-dataset :generic-sql
@db-id)
(datasets/when-testing-dataset :mongo
@mongo-test-data/mongo-test-db-id)]))])
;; Add an extra DB so we have something to fetch besides the Test DB
(create-db db-name)
;; Now hit the endpoint
......
(ns metabase.driver.generic-sql.native-test
(:require [expectations :refer :all]
(:require [clojure.tools.logging :as log]
[colorize.core :as color]
[expectations :refer :all]
[metabase.driver :as driver]
[metabase.test-data :refer :all]))
......@@ -10,7 +12,8 @@
[99]]
:columns [:id]
:cols [{:name :id, :base_type :IntegerField}]}}
(driver/process-query {:native {:query "SELECT ID FROM VENUES ORDER BY ID DESC LIMIT 2;"}
(driver/process-query {:native {:query "SELECT ID FROM VENUES ORDER BY ID DESC LIMIT 2;"}
:type :native
:database @db-id}))
;; Check that column ordering is maintained
......@@ -23,11 +26,14 @@
:cols [{:name :id, :base_type :IntegerField}
{:name :name, :base_type :TextField}
{:name :category_id, :base_type :IntegerField}]}}
(driver/process-query {:native {:query "SELECT ID, NAME, CATEGORY_ID FROM VENUES ORDER BY ID DESC LIMIT 2;"}
(driver/process-query {:native {:query "SELECT ID, NAME, CATEGORY_ID FROM VENUES ORDER BY ID DESC LIMIT 2;"}
:type :native
:database @db-id}))
;; Check that we get proper error responses for malformed SQL
(expect {:status :failed
:error "Column \"ZID\" not found"}
(driver/process-query {:native {:query "SELECT ZID FROM CHECKINS LIMIT 2;"}
:database @db-id}))
(do (log/info (color/green "NOTE: The following stacktrace is expected <3")) ; this will print a stacktrace
(driver/process-query {:native {:query "SELECT ZID FROM CHECKINS LIMIT 2;"} ; make sure people know it's to be expected
:type :native
:database @db-id})))
(ns metabase.driver.generic-sql.query-processor-test
(:require [clojure.math.numeric-tower :as math]
[clojure.tools.logging :as log]
[colorize.core :as color]
[expectations :refer :all]
[metabase.driver :as driver]
[metabase.test-data :refer [db-id table->id field->id]]))
......@@ -10,15 +12,17 @@
(expect
{:status :failed
:error "Column \"CHECKINS.NAME\" not found; SQL statement:\nSELECT \"CHECKINS\".* FROM \"CHECKINS\" WHERE (\"CHECKINS\".\"NAME\" = ?)"}
(driver/process-query {:database @db-id
:type :query
:query {:source_table (table->id :checkins)
:filter ["=" (field->id :venues :name) 1] ; wrong Field
:aggregation ["rows"]
:breakout [nil]
:limit nil}}))
;; This will print a stacktrace. Better to reassure people that that's on purpose than to make people question whether the tests are working
(do (log/info (color/green "NOTE: The following stacktrace is expected <3"))
(driver/process-query {:database @db-id
:type :query
:query {:source_table (table->id :checkins)
:filter ["=" (field->id :venues :name) 1] ; wrong Field
:aggregation ["rows"]
:breakout [nil]
:limit nil}})))
;; # ---------------------------------------- TODO - ONES THAT STILL NEED TO BE MOVED OVER ----------------------------------------
;; # ---------------------------------------- TODO - ONES THAT STILL NEED TO BE MOVED OVER (MONGO DOESN'T SUPPORT STDDEV YET) ----------------------------------------
;; ## "STDDEV" AGGREGATION
(expect {:status :completed
......
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