Skip to content
Snippets Groups Projects
Commit 9837d5eb authored by Allen Gilliland's avatar Allen Gilliland
Browse files

add a unit test for the new api endpoint scenario.

parent 0a9a9e0e
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,22 @@
:description nil
:features (mapv name (driver/features (driver/engine->driver (:engine db))))})))
(defn- table-details [table]
(match-$ table
{:description $
:entity_type $
:visibility_type $
:schema $
:name $
:display_name $
:rows $
:updated_at $
:entity_name $
:active $
:id $
:db_id $
:created_at $}))
;; # DB LIFECYCLE ENDPOINTS
......@@ -149,6 +165,49 @@
;; Now hit the endpoint
(set ((user->client :rasta) :get 200 "database")))))
;; GET /api/databases (include tables)
(let [db-name (str "A" (random-name))] ; make sure this name comes before "test-data"
(expect-eval-actual-first
(set (filter identity (conj (for [engine datasets/all-valid-engines]
(datasets/when-testing-engine engine
(match-$ (get-or-create-test-data-db! (driver/engine->driver engine))
{:created_at $
:engine (name $engine)
:id $
:updated_at $
:name "test-data"
:is_sample false
:is_full_sync true
:organization_id nil
:description nil
:tables [(table-details (Table (id :categories)))
(table-details (Table (id :checkins)))
(table-details (Table (id :users)))
(table-details (Table (id :venues)))]
:features (mapv name (driver/features (driver/engine->driver engine)))})))
;; (?) I don't remember why we have to do this for postgres but not any other of the bonus drivers
(match-$ (sel :one Database :name db-name)
{:created_at $
:engine "postgres"
:id $
:updated_at $
:name $
:is_sample false
:is_full_sync true
:organization_id nil
:description nil
:tables []
:features (mapv name (driver/features (driver/engine->driver :postgres)))}))))
(do
;; Delete all the randomly created Databases we've made so far
(cascade-delete Database :id [not-in (set (filter identity
(for [engine datasets/all-valid-engines]
(datasets/when-testing-engine engine
(:id (get-or-create-test-data-db! (driver/engine->driver engine)))))))])
;; Add an extra DB so we have something to fetch besides the Test DB
(create-db db-name)
;; Now hit the endpoint
(set ((user->client :rasta) :get 200 "database" :include_tables true)))))
;; ## GET /api/meta/table/:id/query_metadata
;; TODO - add in example with Field :values
......
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