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
b9309797
Commit
b9309797
authored
9 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
test cleanup
parent
3746d13b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/metabase/api/revision_test.clj
+23
-17
23 additions, 17 deletions
test/metabase/api/revision_test.clj
with
23 additions
and
17 deletions
test/metabase/api/revision_test.clj
+
23
−
17
View file @
b9309797
...
...
@@ -30,22 +30,30 @@
(
with-fake-card
[{
card-id
:id
}]
((
user->client
:rasta
)
:get
200
"revision"
,
:entity
:card,
:id
card-id
)))
(
defn-
get-dashboard-revisions
[
dashboard-id
]
(
->>
((
user->client
:rasta
)
:get
200
"revision"
,
:entity
:dashboard,
:id
dashboard-id
)
(
mapv
#
(
dissoc
%
:timestamp
:id
))))
(
defn-
post-dashcard
[
dash-id
card-id
]
((
user->client
:rasta
)
:post
200
(
format
"dash/%d/cards"
dash-id
)
,
{
:cardId
card-id
}))
(
defn-
delete-dashcard
[
dash-id
card-id
]
((
user->client
:rasta
)
:delete
204
(
format
"dash/%d/cards"
dash-id
)
,
:dashcardId
(
db/sel
:one
:id
DashboardCard
:dashboard_id
dash-id,
:card_id
card-id
)))
(
expect
[{
:is_reversion
false,
:user
@
rasta-revision-info,
:description
"First revision."
}]
(
with-fake-dashboard
[{
dash-id
:id
}]
(
with-fake-card
[{
card-id
:id
}]
((
user->client
:rasta
)
:post
200
(
format
"dash/%d/cards"
dash-id
)
,
{
:cardId
card-id
})
(
->>
((
user->client
:rasta
)
:get
200
"revision"
,
:entity
:dashboard,
:id
dash-id
)
(
mapv
#
(
dissoc
%
:timestamp
:id
))))))
(
post-dashcard
dash-id
card-id
)
(
get-dashboard-revisions
dash-id
))))
(
expect
[{
:is_reversion
false,
:user
@
rasta-revision-info,
:description
"Rasta Toucan added a card."
}
{
:is_reversion
false,
:user
@
rasta-revision-info,
:description
"First revision."
}]
(
with-fake-dashboard
[{
dash-id
:id
}]
(
with-fake-card
[{
card-id
₁
:id
}]
(
with-fake-card
[{
card-id
₂
:id
}]
((
user->client
:rasta
)
:post
200
(
format
"dash/%d/cards"
dash-id
)
,
{
:cardId
card-id
₁
})
((
user->client
:rasta
)
:post
200
(
format
"dash/%d/cards"
dash-id
)
,
{
:cardId
card-id
₂
})
(
->>
((
user->client
:rasta
)
:get
200
"revision"
,
:entity
:dashboard,
:id
dash-id
)
(
mapv
#
(
dissoc
%
:timestamp
:id
)))))))
(
post-dashcard
dash-id
card-id
₁
)
(
post-dashcard
dash-id
card-id
₂
)
(
get-dashboard-revisions
dash-id
)))))
(
expect
[{
:is_reversion
false,
:user
@
rasta-revision-info,
:description
"Rasta Toucan removed a card."
}
{
:is_reversion
false,
:user
@
rasta-revision-info,
:description
"Rasta Toucan added a card."
}
...
...
@@ -53,11 +61,10 @@
(
with-fake-dashboard
[{
dash-id
:id
}]
(
with-fake-card
[{
card-id
₁
:id
}]
(
with-fake-card
[{
card-id
₂
:id
}]
((
user->client
:rasta
)
:post
200
(
format
"dash/%d/cards"
dash-id
)
,
{
:cardId
card-id
₁
})
((
user->client
:rasta
)
:post
200
(
format
"dash/%d/cards"
dash-id
)
,
{
:cardId
card-id
₂
})
((
user->client
:rasta
)
:delete
204
(
format
"dash/%d/cards"
dash-id
)
,
:dashcardId
(
db/sel
:one
:id
DashboardCard
(
k/order
:id
:desc
)))
(
->>
((
user->client
:rasta
)
:get
200
"revision"
,
:entity
:dashboard,
:id
dash-id
)
(
mapv
#
(
dissoc
%
:timestamp
:id
)))))))
(
post-dashcard
dash-id
card-id
₁
)
(
post-dashcard
dash-id
card-id
₂
)
(
delete-dashcard
dash-id
card-id
₂
)
(
get-dashboard-revisions
dash-id
)))))
;;; # TESTS FOR POST /api/revision/revert
(
expect
[
2
...
...
@@ -68,14 +75,13 @@
(
with-fake-dashboard
[{
dash-id
:id
}]
(
with-fake-card
[{
card-id
₁
:id
}]
(
with-fake-card
[{
card-id
₂
:id
}]
(
(
user->client
:rasta
)
:post
200
(
format
"dash/%d/
card
s"
dash-id
)
,
{
:cardId
card-id
₁
}
)
(
(
user->client
:rasta
)
:post
200
(
format
"dash/%d/
card
s"
dash-id
)
,
{
:cardId
card-id
₂
}
)
(
(
user->client
:rasta
)
:delete
204
(
format
"dash/%d/
card
s"
dash-id
)
,
:dashcardId
(
db/sel
:one
:id
DashboardCard
(
k/order
:id
:desc
))
)
(
post-dash
card
dash-id
card-id
₁
)
(
post-dash
card
dash-id
card-id
₂
)
(
delete-dash
card
dash-id
card-id
₂
)
(
let
[[
_
{
previous-revision-id
:id
}]
(
metabase.models.revision/revisions
Dashboard
dash-id
)]
;; Revert to the previous revision
((
user->client
:rasta
)
:post
200
"revision/revert"
,
{
:entity
:dashboard,
:id
dash-id,
:revision_id
previous-revision-id
})
[
;; [1] There should be 2 cards again
(
count
@
(
:ordered_cards
(
Dashboard
dash-id
)))
;; [2] A new revision recording the reversion should have been pushed
(
->>
((
user->client
:rasta
)
:get
200
"revision"
,
:entity
:dashboard,
:id
dash-id
)
(
mapv
#
(
dissoc
%
:timestamp
:id
)))])))))
(
get-dashboard-revisions
dash-id
)])))))
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