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
4472564b
Commit
4472564b
authored
7 years ago
by
Arthur Ulfeldt
Browse files
Options
Downloads
Patches
Plain Diff
more code review improvements
parent
6d3b7953
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/sync_database/analyze_test.clj
+48
-42
48 additions, 42 deletions
test/metabase/sync_database/analyze_test.clj
with
48 additions
and
42 deletions
test/metabase/sync_database/analyze_test.clj
+
48
−
42
View file @
4472564b
...
...
@@ -88,8 +88,8 @@
(
db/count
Field
:table_id
table-id
)))
(
db/count
Field
:last_analyzed
nil
:table_id
table-id
)))
(
defn
latest-sync-time
[
db_id
table-nam
e
]
(
let
[
table-id
(
db/select-one-id
Table
,
:db_id
db_id
,
:active
true
:name
table-name
)]
(
defn
latest-sync-time
[
tabl
e
]
(
let
[
table-id
(
db/select-one-id
Table
:db_id
(
:
db_id
table
)
:active
true
:name
(
:name
table
)
)]
(
db/select-field
:last_analyzed
Field
:table_id
table-id
)))
(
defn
set-table-visibility-type!
[
table
visibility-type
]
...
...
@@ -106,52 +106,58 @@
(
analyze-data-shape-for-tables!
(
driver/database-id->driver
db-id
)
{
:id
db-id
})))
;; expect all the kinds of hidden tables to stay un-analyzed through transitions and repeated syncing
(
tt/expect-with-temp
[
Table
[
table
{
:rows
15
}]
Field
[
field
{
:table_id
(
:id
table
)}]]
(
expect
1
(
do
(
set-table-visibility-type!
table
"hidden"
)
(
api-sync-call
table
)
(
set-table-visibility-type!
table
"cruft"
)
(
set-table-visibility-type!
table
"cruft"
)
(
api-sync-call
table
)
(
set-table-visibility-type!
table
"technical"
)
(
api-sync-call
table
)
(
set-table-visibility-type!
table
"technical"
)
(
api-sync-call
table
)
(
api-sync-call
table
)
(
count-unanalyzed-fields
(
:db_id
table
)
(
:name
table
))))
(
tt/with-temp*
[
Table
[
table
{
:rows
15
}]
Field
[
field
{
:table_id
(
:id
table
)}]]
(
do
(
set-table-visibility-type!
table
"hidden"
)
(
api-sync-call
table
)
(
set-table-visibility-type!
table
"cruft"
)
(
set-table-visibility-type!
table
"cruft"
)
(
api-sync-call
table
)
(
set-table-visibility-type!
table
"technical"
)
(
api-sync-call
table
)
(
set-table-visibility-type!
table
"technical"
)
(
api-sync-call
table
)
(
api-sync-call
table
)
(
count-unanalyzed-fields
(
:db_id
table
)
(
:name
table
)))))
;; same test not coming through the api
(
tt/expect-with-temp
[
Table
[
table
{
:rows
15
}]
Field
[
field
{
:table_id
(
:id
table
)}]]
(
expect
1
(
do
(
set-table-visibility-type!
table
"hidden"
)
(
sync-call
table
)
(
set-table-visibility-type!
table
"cruft"
)
(
set-table-visibility-type!
table
"cruft"
)
(
sync-call
table
)
(
set-table-visibility-type!
table
"technical"
)
(
sync-call
table
)
(
set-table-visibility-type!
table
"technical"
)
(
sync-call
table
)
(
sync-call
table
)
(
count-unanalyzed-fields
(
:db_id
table
)
(
:name
table
))))
(
tt/with-temp*
[
Table
[
table
{
:rows
15
}]
Field
[
field
{
:table_id
(
:id
table
)}]]
(
do
(
set-table-visibility-type!
table
"hidden"
)
(
sync-call
table
)
(
set-table-visibility-type!
table
"cruft"
)
(
set-table-visibility-type!
table
"cruft"
)
(
sync-call
table
)
(
set-table-visibility-type!
table
"technical"
)
(
sync-call
table
)
(
set-table-visibility-type!
table
"technical"
)
(
sync-call
table
)
(
sync-call
table
)
(
count-unanalyzed-fields
(
:db_id
table
)
(
:name
table
)))))
;; un-hiding a table should cause it to be analyzed
(
tt/expect-with-temp
[
Table
[
table
{
:rows
15
}]
Field
[
field
{
:table_id
(
:id
table
)}]]
(
expect
0
(
do
(
set-table-visibility-type!
table
"hidden"
)
(
set-table-visibility-type!
table
nil
)
(
count-unanalyzed-fields
(
:db_id
table
)
(
:name
table
))))
(
tt/with-temp*
[
Table
[
table
{
:rows
15
}]
Field
[
field
{
:table_id
(
:id
table
)}]]
(
do
(
set-table-visibility-type!
table
"hidden"
)
(
set-table-visibility-type!
table
nil
)
(
count-unanalyzed-fields
(
:db_id
table
)
(
:name
table
)))))
;; re-hiding a table should not cause it to be analyzed
(
tt/expect-with-temp
[
Table
[
table
{
:rows
15
}]
Field
[
field
{
:table_id
(
:id
table
)}]]
true
(
do
(
set-table-visibility-type!
table
"hidden"
)
;; start with it not visible
(
set-table-visibility-type!
table
nil
)
;; make it visible to trigger analysis
(
let
[
initial-sync-time
(
latest-sync-time
(
:db_id
table
)
(
:name
table
))]
;; make it invisible which should not trigger analysis
(
set-table-visibility-type!
table
"hidden"
)
(
=
initial-sync-time
(
latest-sync-time
(
:db_id
table
)
(
:name
table
))))))
(
expect
;; create an initially hidden table
(
tt/with-temp*
[
Table
[
table
{
:rows
15
,
:visibility_type
"hidden"
}]
Field
[
field
{
:table_id
(
:id
table
)}]]
;; switch the table to visible (triggering a sync) and get the last sync time
(
let
[
last-sync-time
(
do
(
set-table-visibility-type!
table
nil
)
(
latest-sync-time
table
))]
;; now make it hidden again
(
set-table-visibility-type!
table
"hidden"
)
;; sync time shouldn't change
(
=
last-sync-time
(
latest-sync-time
table
)))))
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