Skip to content
Snippets Groups Projects
Commit 337a2839 authored by Cam Saül's avatar Cam Saül
Browse files

Merge pull request #169 from metabase/test_cleanup

use @org-id instead of (:id @test-org)
parents e9dedb65 7e82ab1b
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@
;; ## Helper fns
(defn post-card [card-name]
((user->client :rasta) :post 200 "card" {:organization (:id @test-org)
((user->client :rasta) :post 200 "card" {:organization @org-id
:name card-name
:public_perms 0
:can_read true
......@@ -31,7 +31,7 @@
(let [card-name (random-name)]
(expect-eval-actual-first (match-$ (sel :one Card :name card-name)
{:description nil
:organization_id (:id @test-org)
:organization_id @org-id
:name card-name
:creator_id (user->id :rasta)
:updated_at $
......@@ -41,7 +41,7 @@
:aggregation ["count"]
:breakout [nil]
:limit nil}
:database (:id @test-org)}
:database @org-id}
:id $
:display "scalar"
:visualization_settings {:global {:title nil}}
......@@ -57,14 +57,14 @@
{:description nil
:can_read true
:can_write true
:organization_id (:id @test-org)
:organization_id @org-id
:name card-name
:organization {:inherits true
:logo_url nil
:description nil
:name "Test Organization"
:slug "test"
:id (:id @test-org)}
:id @org-id}
:creator_id (user->id :rasta)
:updated_at $
:dataset_query {:type "query"
......
......@@ -17,7 +17,7 @@
;; ## Helper Fns
(defn create-dash [dash-name]
((user->client :rasta) :post 200 "dash" {:name dash-name
:organization (:id @test-org)
:organization @org-id
:public_perms 0}))
;; ## POST /api/dash
......@@ -46,7 +46,7 @@
:creator (-> (sel :one User :id (user->id :rasta))
(select-keys [:email :first_name :last_login :is_superuser :id :last_name :date_joined :common_name]))
:can_write true
:organization_id (:id @test-org)
:organization_id @org-id
:name $
:organization (-> @test-org
(select-keys [:inherits :logo_url :description :name :slug :id]))
......@@ -103,7 +103,7 @@
{:description nil
:creator (-> (sel :one User :id (user->id :rasta))
(select-keys [:date_joined :last_name :id :is_superuser :last_login :first_name :email :common_name]))
:organization_id (:id @test-org)
:organization_id @org-id
:name $
:creator_id (user->id :rasta)
:updated_at $
......
......@@ -34,7 +34,7 @@
:sun true}
:time_of_day "morning"
:timezone ""}
:organization (:id @test-org)}
:organization @org-id}
kwargs)))
;; ## GET /api/emailreport/form_input
......@@ -74,7 +74,7 @@
:permissions [{:name "None", :id 0}
{:name "Read Only", :id 1}
{:name "Read & Write", :id 2}]}
(-> ((user->client :rasta) :get 200 "emailreport/form_input" :org (:id @test-org)) ; convert to a set so test doesn't fail if order differs
(-> ((user->client :rasta) :get 200 "emailreport/form_input" :org @org-id) ; convert to a set so test doesn't fail if order differs
(update-in [:users] set)))
......@@ -92,7 +92,7 @@
:sun true}
:timezone ""
:time_of_day "morning"}
:organization_id (:id @test-org)
:organization_id @org-id
:name "My Cool Email Report"
:mode (emailreport/mode->id :active)
:creator_id (user->id :rasta)
......@@ -135,10 +135,10 @@
:first_name "Rasta"
:email "rasta@metabase.com"})
:can_write true
:organization_id (:id @test-org)
:organization_id @org-id
:name "My Cool Email Report"
:mode (emailreport/mode->id :active)
:organization {:id (:id @test-org)
:organization {:id @org-id
:slug "test"
:name "Test Organization"
:description nil
......
......@@ -9,7 +9,7 @@
;; HELPER FNS
(defn create-db [db-name]
((user->client :rasta) :post 200 "meta/db" {:org (:id @test-org)
((user->client :rasta) :post 200 "meta/db" {:org @org-id
:engine :postgres
:name db-name
:details {:conn_str "host=localhost port=5432 dbname=fakedb user=cam"}}))
......@@ -42,14 +42,14 @@
:id $
:details $
:updated_at $
:organization {:id (:id @test-org)
:organization {:id @org-id
:slug "test"
:name "Test Organization"
:description nil
:logo_url nil
:inherits true}
:name "Test Database"
:organization_id (:id @test-org)
:organization_id @org-id
:description nil})
((user->client :rasta) :get 200 (format "meta/db/%d" (:id @test-db))))
......@@ -64,7 +64,7 @@
:details {:conn_str "host=localhost port=5432 dbname=fakedb user=cam"}
:updated_at $
:name db-name
:organization_id (:id @test-org)
:organization_id @org-id
:description nil})
(create-db db-name)))
......@@ -115,14 +115,14 @@
:id $
:details {:conn_str "host=localhost port=5432 dbname=fakedb user=cam"}
:updated_at $
:organization {:id (:id @test-org)
:organization {:id @org-id
:slug "test"
:name "Test Organization"
:description nil
:logo_url nil
:inherits true}
:name $
:organization_id (:id @test-org)
:organization_id @org-id
:description nil})
(match-$ @test-db
{:created_at $
......@@ -130,22 +130,22 @@
:id $
:details $
:updated_at $
:organization {:id (:id @test-org)
:organization {:id @org-id
:slug "test"
:name "Test Organization"
:description nil
:logo_url nil
:inherits true}
:name "Test Database"
:organization_id (:id @test-org)
:organization_id @org-id
:description nil})]
(do
;; Delete all the randomly created Databases we've made so far
(cascade-delete Database :organization_id (:id @test-org) :id [not= (:id @test-db)])
(cascade-delete Database :organization_id @org-id :id [not= (:id @test-db)])
;; Add an extra DB so we have something to fetch besides the Test DB
(create-db db-name)
;; Now hit the endpoint
((user->client :rasta) :get 200 "meta/db" :org (:id @test-org)))))
((user->client :rasta) :get 200 "meta/db" :org @org-id))))
;; # DB TABLES ENDPOINTS
......
......@@ -24,7 +24,7 @@
:details $
:updated_at $
:name "Test Database"
:organization_id (:id @test-org)
:organization_id @org-id
:description nil})
:name "USERS"
:rows 15
......
......@@ -29,7 +29,7 @@
:details $
:updated_at $
:name "Test Database"
:organization_id (:id @test-org)
:organization_id @org-id
:description nil})
:name "VENUES"
:rows 100
......@@ -82,7 +82,7 @@
:details $
:updated_at $
:name "Test Database"
:organization_id (:id @test-org)
:organization_id @org-id
:description nil})
:name "CATEGORIES"
:fields [(match-$ (sel :one Field :id (field->id :categories :name))
......
......@@ -19,7 +19,7 @@
;; ## GET /api/org
;; Non-superusers should only be able to see Orgs they are members of
(expect
[{:id (:id @test-org)
[{:id @org-id
:slug "test"
:name "Test Organization"
:description nil
......@@ -30,7 +30,7 @@
;; Superusers should be able to see all Orgs
(let [org-name (random-name)]
(expect-eval-actual-first
[{:id (:id @test-org)
[{:id @org-id
:slug "test"
:name "Test Organization"
:description nil
......@@ -45,7 +45,7 @@
:inherits false})]
(do
;; Delete all the random test Orgs we've created
(cascade-delete Org :id [not= (:id @test-org)])
(cascade-delete Org :id [not= @org-id])
;; Create a random Org so we can check that we still get Orgs we're not members of
(create-org org-name)
;; Now perform the API request
......@@ -53,17 +53,17 @@
;; ## GET /api/org/:id
(expect
{:id (:id @test-org)
{:id @org-id
:slug "test"
:name "Test Organization"
:description nil
:logo_url nil
:inherits true}
((user->client :rasta) :get 200 (format "org/%d" (:id @test-org))))
((user->client :rasta) :get 200 (format "org/%d" @org-id)))
;; ## GET /api/org/slug/:slug
(expect
{:id (:id @test-org)
{:id @org-id
:slug "test"
:name "Test Organization"
:description nil
......@@ -99,7 +99,7 @@
{:id $
:admin true
:user_id (user->id :crowberto)
:organization_id (:id @test-org)
:organization_id @org-id
:user (match-$ (fetch-user :crowberto)
{:common_name "Crowberto Corv"
:date_joined $
......@@ -113,7 +113,7 @@
{:id $
:admin false
:user_id (user->id :trashbird)
:organization_id (:id @test-org)
:organization_id @org-id
:user (match-$ (fetch-user :trashbird)
{:common_name "Trash Bird"
:date_joined $
......@@ -127,7 +127,7 @@
{:id $
:admin false
:user_id (user->id :lucky)
:organization_id (:id @test-org)
:organization_id @org-id
:user (match-$ (fetch-user :lucky)
{:common_name "Lucky Pigeon"
:date_joined $
......@@ -141,7 +141,7 @@
{:id $
:admin true
:user_id (user->id :rasta)
:organization_id (:id @test-org)
:organization_id @org-id
:user (match-$ (fetch-user :rasta)
{:common_name "Rasta Toucan"
:date_joined $
......@@ -151,7 +151,7 @@
:last_login $
:first_name "Rasta"
:email "rasta@metabase.com"})})}
(set ((user->client :rasta) :get 200 (format "org/%d/members" (:id @test-org)))))
(set ((user->client :rasta) :get 200 (format "org/%d/members" @org-id))))
;; ## Helper Fns
......
......@@ -36,8 +36,8 @@
{:name "Read & Write", :id 2}]}
(do
@test-db ; force lazy creation of test data / Metabase DB if it doesn't already exist
(cascade-delete Database :organization_id (:id @test-org) :id [not= (:id @test-db)]) ; delete any other rando test DBs made by other tests
((user->client :rasta) :get 200 "query/form_input" :org (:id @test-org))))
(cascade-delete Database :organization_id @org-id :id [not= (:id @test-db)]) ; delete any other rando test DBs made by other tests
((user->client :rasta) :get 200 "query/form_input" :org @org-id)))
;; ## POST /api/query (create)
;; Check that we can save a Query
......@@ -76,7 +76,7 @@
:details $
:updated_at $
:name "Test Database"
:organization_id (:id @test-org)
:organization_id @org-id
:description nil})
:creator (match-$ (fetch-user :rasta)
{:common_name "Rasta Toucan"
......@@ -204,7 +204,7 @@
:details $
:updated_at $
:name "Test Database"
:organization_id (:id @test-org)
:organization_id @org-id
:description nil})]
[(match-$ query-1
{:creator rasta
......@@ -237,7 +237,7 @@
(do (cascade-delete Query :database_id (:id @test-db))
(create-query)
(create-query)
((user->client :rasta) :get 200 "query" :org (:id @test-org))))
((user->client :rasta) :get 200 "query" :org @org-id)))
;; ## POST /api/query/:id/csv
......
......@@ -150,7 +150,7 @@
"Return the `OrgPerm` for User with USERNAME for the Test Org."
[username]
{:pre [(contains? usernames username)]}
(sel :one OrgPerm :organization_id (:id @test-org) :user_id (user->id username)))
(sel :one OrgPerm :organization_id @org-id :user_id (user->id username)))
;; # INTERNAL
......
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