Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
9837d5eb
Commit
9837d5eb
authored
9 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Patches
Plain Diff
add a unit test for the new api endpoint scenario.
parent
0a9a9e0e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/metabase/api/database_test.clj
+59
-0
59 additions, 0 deletions
test/metabase/api/database_test.clj
with
59 additions
and
0 deletions
test/metabase/api/database_test.clj
+
59
−
0
View file @
9837d5eb
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment