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
97715500
Commit
97715500
authored
9 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Patches
Plain Diff
validate the :object of the stored revisions in our unit tests for `(push-revision-event ...)`
parent
d1904645
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/api/dashboard.clj
+1
-1
1 addition, 1 deletion
src/metabase/api/dashboard.clj
test/metabase/events/revision_test.clj
+54
-18
54 additions, 18 deletions
test/metabase/events/revision_test.clj
with
55 additions
and
19 deletions
src/metabase/api/dashboard.clj
+
1
−
1
View file @
97715500
...
...
@@ -105,7 +105,7 @@
(
let
[
dashcard
(
sel
:one
[
DashboardCard
:id
]
:id
dashcard-id
:dashboard_id
id
)]
(
when
dashcard
(
upd
DashboardCard
dashcard-id
:sizeX
sizeX
:sizeY
sizeY
:row
row
:col
col
))))
(
events/publish-event
:dashboard-reposition-cards
{
:id
id
:actor_id
*current-user-id*
:cards
cards
})
(
events/publish-event
:dashboard-reposition-cards
{
:id
id
:actor_id
*current-user-id*
:
dash
cards
cards
})
{
:status
:ok
})
(
define-routes
)
This diff is collapsed.
Click to expand it.
test/metabase/events/revision_test.clj
+
54
−
18
View file @
97715500
...
...
@@ -20,10 +20,27 @@
:description
rand-name
:public_perms
2
:display
"table"
:dataset_query
{}
:dataset_query
{
:database
(
db-id
)
:type
"query"
:query
{
:aggregation
[
"rows"
]
:source_table
(
id
:categories
)}}
:visualization_settings
{}
:creator_id
(
user->id
:crowberto
))))
(
defn-
test-card-object
[
card
]
{
:description
(
:name
card
)
,
:table_id
(
id
:categories
)
,
:database_id
(
db-id
)
,
:organization_id
nil,
:query_type
"query"
,
:name
(
:name
card
)
,
:creator_id
(
user->id
:crowberto
)
,
:dataset_query
(
:dataset_query
card
)
,
:id
(
:id
card
)
,
:display
"table"
,
:visualization_settings
{}
,
:public_perms
2
})
(
defn-
create-test-dashboard
[]
(
let
[
rand-name
(
random-name
)]
(
db/ins
Dashboard
...
...
@@ -32,65 +49,76 @@
:public_perms
2
:creator_id
(
user->id
:crowberto
))))
(
defn-
test-dashboard-object
[
dashboard
]
{
:description
(
:name
dashboard
)
,
:name
(
:name
dashboard
)
,
:public_perms
2
})
;; :card-create
(
expect-let
[{
card-id
:id
:as
card
}
(
create-test-card
)]
{
:model
"Card"
:model_id
card-id
:user_id
(
user->id
:crowberto
)
:object
(
test-card-object
card
)
:is_reversion
false
:is_creation
true
}
(
do
(
process-revision-event
{
:topic
:card-create
:item
card
})
(
->
(
db/sel
:one
Revision
:model
"Card"
:model_id
card-id
)
(
select-keys
[
:model
:model_id
:user_id
:is_reversion
:is_creation
]))))
(
select-keys
[
:model
:model_id
:user_id
:object
:is_reversion
:is_creation
]))))
;; :card-update
(
expect-let
[{
card-id
:id
:as
card
}
(
create-test-card
)]
{
:model
"Card"
:model_id
card-id
:user_id
(
user->id
:crowberto
)
:object
(
test-card-object
card
)
:is_reversion
false
:is_creation
false
}
(
do
(
process-revision-event
{
:topic
:card-update
:item
card
})
(
->
(
db/sel
:one
Revision
:model
"Card"
:model_id
card-id
)
(
select-keys
[
:model
:model_id
:user_id
:is_reversion
:is_creation
]))))
(
select-keys
[
:model
:model_id
:user_id
:object
:is_reversion
:is_creation
]))))
;; :dashboard-create
(
expect-let
[{
dashboard-id
:id
:as
dashboard
}
(
create-test-dashboard
)]
{
:model
"Dashboard"
:model_id
dashboard-id
:user_id
(
user->id
:crowberto
)
:object
(
assoc
(
test-dashboard-object
dashboard
)
:cards
[])
:is_reversion
false
:is_creation
true
}
(
do
(
process-revision-event
{
:topic
:dashboard-create
:item
dashboard
})
(
->
(
db/sel
:one
Revision
:model
"Dashboard"
:model_id
dashboard-id
)
(
select-keys
[
:model
:model_id
:user_id
:is_reversion
:is_creation
]))))
(
select-keys
[
:model
:model_id
:user_id
:object
:is_reversion
:is_creation
]))))
;; :dashboard-update
(
expect-let
[{
dashboard-id
:id
:as
dashboard
}
(
create-test-dashboard
)]
{
:model
"Dashboard"
:model_id
dashboard-id
:user_id
(
user->id
:crowberto
)
:object
(
assoc
(
test-dashboard-object
dashboard
)
:cards
[])
:is_reversion
false
:is_creation
false
}
(
do
(
process-revision-event
{
:topic
:dashboard-update
:item
dashboard
})
(
->
(
db/sel
:one
Revision
:model
"Dashboard"
:model_id
dashboard-id
)
(
select-keys
[
:model
:model_id
:user_id
:is_reversion
:is_creation
]))))
(
select-keys
[
:model
:model_id
:user_id
:object
:is_reversion
:is_creation
]))))
;; :dashboard-add-cards
(
expect-let
[{
dashboard-id
:id
}
(
create-test-dashboard
)
{
card-id
:id
}
(
create-test-card
)
dashcard
(
db/ins
DashboardCard
:card_id
card-id
:dashboard_id
dashboard-id
)]
(
expect-let
[{
dashboard-id
:id
:as
dashboard
}
(
create-test-dashboard
)
{
card-id
:id
}
(
create-test-card
)
dashcard
(
db/ins
DashboardCard
:card_id
card-id
:dashboard_id
dashboard-id
)]
{
:model
"Dashboard"
:model_id
dashboard-id
:user_id
(
user->id
:crowberto
)
:object
(
assoc
(
test-dashboard-object
dashboard
)
:cards
[(
select-keys
dashcard
[
:id
:card_id
:sizeX
:sizeY
:row
:col
])])
:is_reversion
false
:is_creation
false
}
(
do
...
...
@@ -99,16 +127,17 @@
:actor_id
(
user->id
:crowberto
)
:dashcards
[
dashcard
]}})
(
->
(
db/sel
:one
Revision
:model
"Dashboard"
:model_id
dashboard-id
)
(
select-keys
[
:model
:model_id
:user_id
:is_reversion
:is_creation
]))))
(
select-keys
[
:model
:model_id
:user_id
:object
:is_reversion
:is_creation
]))))
;; :dashboard-remove-cards
(
expect-let
[{
dashboard-id
:id
}
(
create-test-dashboard
)
{
card-id
:id
}
(
create-test-card
)
dashcard
(
db/ins
DashboardCard
:card_id
card-id
:dashboard_id
dashboard-id
)
_
(
db/del
DashboardCard
:id
(
:id
dashcard
))]
(
expect-let
[{
dashboard-id
:id
:as
dashboard
}
(
create-test-dashboard
)
{
card-id
:id
}
(
create-test-card
)
dashcard
(
db/ins
DashboardCard
:card_id
card-id
:dashboard_id
dashboard-id
)
_
(
db/del
DashboardCard
:id
(
:id
dashcard
))]
{
:model
"Dashboard"
:model_id
dashboard-id
:user_id
(
user->id
:crowberto
)
:object
(
assoc
(
test-dashboard-object
dashboard
)
:cards
[])
:is_reversion
false
:is_creation
false
}
(
do
...
...
@@ -117,15 +146,22 @@
:actor_id
(
user->id
:crowberto
)
:dashcards
[
dashcard
]}})
(
->
(
db/sel
:one
Revision
:model
"Dashboard"
:model_id
dashboard-id
)
(
select-keys
[
:model
:model_id
:user_id
:is_reversion
:is_creation
]))))
(
select-keys
[
:model
:model_id
:user_id
:object
:is_reversion
:is_creation
]))))
;; :dashboard-reposition-cards
(
expect-let
[{
dashboard-id
:id
}
(
create-test-dashboard
)
{
card-id
:id
}
(
create-test-card
)
dashcard
(
db/ins
DashboardCard
:card_id
card-id
:dashboard_id
dashboard-id
)]
(
expect-let
[{
dashboard-id
:id
:as
dashboard
}
(
create-test-dashboard
)
{
card-id
:id
}
(
create-test-card
)
dashcard
(
db/ins
DashboardCard
:card_id
card-id
:dashboard_id
dashboard-id
)
_
(
db/upd
DashboardCard
(
:id
dashcard
)
:sizeX
4
)]
{
:model
"Dashboard"
:model_id
dashboard-id
:user_id
(
user->id
:crowberto
)
:object
(
assoc
(
test-dashboard-object
dashboard
)
:cards
[{
:id
(
:id
dashcard
)
:card_id
card-id
:sizeX
4
:sizeY
2
:row
nil
:col
nil
}])
:is_reversion
false
:is_creation
false
}
(
do
...
...
@@ -134,4 +170,4 @@
:actor_id
(
user->id
:crowberto
)
:dashcards
[(
assoc
dashcard
:sizeX
4
)]}})
(
->
(
db/sel
:one
Revision
:model
"Dashboard"
:model_id
dashboard-id
)
(
select-keys
[
:model
:model_id
:user_id
:is_reversion
:is_creation
]))))
(
select-keys
[
:model
:model_id
:user_id
:object
:is_reversion
:is_creation
]))))
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