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
72769e07
Unverified
Commit
72769e07
authored
1 year ago
by
Ryan Kienstra
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Add unit tests for 2 `/api/persist/` endpoints (#33776)
parent
fa94e6e5
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/persist_test.clj
+38
-1
38 additions, 1 deletion
test/metabase/api/persist_test.clj
with
38 additions
and
1 deletion
test/metabase/api/persist_test.clj
+
38
−
1
View file @
72769e07
...
...
@@ -4,7 +4,8 @@
[
metabase.models.database
:refer
[
Database
]]
[
metabase.task.persist-refresh
:as
task.persist-refresh
]
[
metabase.test
:as
mt
]
[
metabase.test.fixtures
:as
fixtures
]))
[
metabase.test.fixtures
:as
fixtures
]
[
metabase.util
:as
u
]))
(
use-fixtures
:once
(
fixtures/initialize
:db
:test-users
))
...
...
@@ -43,3 +44,39 @@
(
is
(
=
default-cron
(
get-in
(
task.persist-refresh/job-info-by-db-id
)
[(
:id
db
)
:schedule
])))))))
(
deftest
persisted-info-by-id-test
(
with-setup
db
(
mt/with-temp
[
:model/Card
model
{
:database_id
(
u/the-id
db
)
,
:dataset
true
}
:model/PersistedInfo
pinfo
{
:database_id
(
u/the-id
db
)
,
:card_id
(
u/the-id
model
)}]
(
testing
"Should require a non-negative persisted-info-id"
(
is
(
=
"API endpoint does not exist."
(
mt/user-http-request
:crowberto
:get
404
(
format
"persist/%d"
-1
)))))
(
testing
"Should not get info when the persisted-info-id doesn't exist"
(
is
(
=
"Not found."
(
mt/user-http-request
:crowberto
:get
404
(
format
"persist/%d"
Integer/MAX_VALUE
)))))
(
testing
"Should get info when the ID exists"
(
is
(
=?
{
:active
true
:card_id
(
u/the-id
model
)
:id
(
u/the-id
pinfo
)
:state
"persisted"
}
(
mt/user-http-request
:crowberto
:get
200
(
format
"persist/%d"
(
u/the-id
pinfo
)))))))))
(
deftest
persisted-info-by-card-id-test
(
with-setup
db
(
mt/with-temp
[
:model/Card
model
{
:database_id
(
u/the-id
db
)
,
:dataset
true
}
:model/PersistedInfo
pinfo
{
:database_id
(
u/the-id
db
)
,
:card_id
(
u/the-id
model
)}]
(
testing
"Should require a non-negative card-id"
(
is
(
=
"API endpoint does not exist."
(
mt/user-http-request
:crowberto
:get
404
(
format
"persist/card/%d"
-1
)))))
(
testing
"Should not get info when the card-id doesn't exist"
(
is
(
=
"Not found."
(
mt/user-http-request
:crowberto
:get
404
(
format
"persist/card/%d"
Integer/MAX_VALUE
)))))
(
testing
"Should get info when the ID exists"
(
is
(
=?
{
:active
true
:card_id
(
u/the-id
model
)
:id
(
u/the-id
pinfo
)
:state
"persisted"
}
(
mt/user-http-request
:crowberto
:get
200
(
format
"persist/card/%d"
(
u/the-id
model
)))))))))
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