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
a52acb96
Commit
a52acb96
authored
7 years ago
by
Arthur Ulfeldt
Browse files
Options
Downloads
Patches
Plain Diff
code-cleanup
parent
89745fa0
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
+11
-12
11 additions, 12 deletions
test/metabase/sync_database/analyze_test.clj
with
11 additions
and
12 deletions
test/metabase/sync_database/analyze_test.clj
+
11
−
12
View file @
a52acb96
...
...
@@ -10,7 +10,8 @@
[
metabase.test.util
:as
tu
]
[
toucan.db
:as
db
]
[
toucan.util.test
:as
tt
]
[
metabase.driver
:as
driver
]))
[
metabase.driver
:as
driver
]
[
metabase.models.field
:as
field
]))
;; test:cardinality-and-extract-field-values
;; (#2332) check that if field values are long we skip over them
...
...
@@ -80,16 +81,16 @@
(
expect
false
(
values-are-valid-emails?
[
"false"
]))
;; Tests to avoid analyzing hidden tables
(
defn
count-un
-
analyzed-fields
[
db_id
table-name
]
(
let
[
table-id
(
db/select-one-id
table/
Table,
:db_id
db_id,
:active
true
:name
table-name
)]
(
defn
count-unanalyzed-fields
[
db_id
table-name
]
(
let
[
table-id
(
db/select-one-id
Table,
:db_id
db_id,
:active
true
:name
table-name
)]
(
assert
(
pos?
;; don't let ourselves be fooled if the test passes because the table is
;; totally broken or has no fields. Make sure we actually test something
(
db/count
metabase.models.field/
Field
:table_id
table-id
)))
(
db/count
metabase.models.field/
Field
:last_analyzed
nil
:table_id
table-id
)))
(
db/count
Field
:table_id
table-id
)))
(
db/count
Field
:last_analyzed
nil
:table_id
table-id
)))
(
defn
get-latest-sync-time
[
db_id
table-name
]
(
let
[
table-id
(
db/select-one-id
table/
Table,
:db_id
db_id,
:active
true
:name
table-name
)]
(
db/select-field
:last_analyzed
metabase.models.field/
Field
:table_id
table-id
)))
(
let
[
table-id
(
db/select-one-id
Table,
:db_id
db_id,
:active
true
:name
table-name
)]
(
db/select-field
:last_analyzed
Field
:table_id
table-id
)))
(
defn
api-table-call
[
state
table
]
...
...
@@ -119,7 +120,7 @@
(
api-table-call
"technical"
table
)
(
api-sync-call
table
)
(
api-sync-call
table
)
(
count-un
-
analyzed-fields
(
:db_id
table
)
(
:name
table
))))
(
count-unanalyzed-fields
(
:db_id
table
)
(
:name
table
))))
;; same test not coming through the api
(
tt/expect-with-temp
[
Table
[
table
{
:rows
15
}]
...
...
@@ -135,7 +136,7 @@
(
api-table-call
"technical"
table
)
(
sync-call
table
)
(
sync-call
table
)
(
count-un
-
analyzed-fields
(
:db_id
table
)
(
:name
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
}]
...
...
@@ -143,15 +144,13 @@
0
(
do
(
api-table-call
"hidden"
table
)
(
api-table-call
nil
table
)
(
count-un
-
analyzed-fields
(
:db_id
table
)
(
:name
table
))))
(
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
)}]]
(
do
(
api-table-call
"hidden"
table
)
(
api-table-call
nil
table
)
(
println
(
get-latest-sync-time
(
:db_id
table
)
(
:name
table
)))
(
get-latest-sync-time
(
:db_id
table
)
(
:name
table
)))
(
do
(
api-table-call
"hidden"
table
)
(
println
(
get-latest-sync-time
(
:db_id
table
)
(
:name
table
)))
(
get-latest-sync-time
(
:db_id
table
)
(
:name
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