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
9da95541
Unverified
Commit
9da95541
authored
11 months ago
by
Cal Herries
Committed by
GitHub
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
CSV uploads: Add test for appending duplicate data (#42918)
parent
4b7f04a8
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/upload_test.clj
+26
-0
26 additions, 0 deletions
test/metabase/upload_test.clj
with
26 additions
and
0 deletions
test/metabase/upload_test.clj
+
26
−
0
View file @
9da95541
...
...
@@ -11,6 +11,7 @@
[
metabase.analytics.snowplow-test
:as
snowplow-test
]
[
metabase.driver
:as
driver
]
[
metabase.driver.ddl.interface
:as
ddl.i
]
[
metabase.driver.mysql
:as
mysql
]
[
metabase.driver.sql-jdbc.connection
:as
sql-jdbc.conn
]
[
metabase.driver.util
:as
driver.u
]
[
metabase.lib.core
:as
lib
]
...
...
@@ -1391,6 +1392,31 @@
(
set
(
rows-for-table
table
)))))
(
io/delete-file
file
))))))))
(
deftest
append-duplicate-test
(
mt/test-drivers
(
mt/normal-drivers-with-feature
:uploads
)
(
testing
"Append should add new rows even if it is the same as the original upload."
(
let
[
csv-rows
[
"id,name"
"10,Luke Skywalker"
"20,Darth Vader"
]
parsed-rows
[[
10
"Luke Skywalker"
]
[
20
"Darth Vader"
]]]
(
with-upload-table!
[
table
(
create-upload-table!
{
:col->upload-type
(
columns-with-auto-pk
(
ordered-map/ordered-map
:id
int-type
:name
vchar-type
))
:rows
parsed-rows
})]
(
let
[
file
(
csv-file-with
csv-rows
)]
(
is
(
some?
(
update-csv!
::upload/append
{
:file
file,
:table-id
(
:id
table
)})))
(
testing
"Check the data was uploaded into the table correctly"
(
if
(
mysql/mariadb?
(
mt/db
))
;; For MariaDB, the auto-incrementing column isn't continuous if the insert is duplicated. So this test
;; skips checking the auto-incrementing column.
(
let
[
drop-auto-pk
#
(
map
rest
%
)]
(
is
(
=
(
concat
parsed-rows
parsed-rows
)
(
drop-auto-pk
(
rows-for-table
table
)))))
(
is
(
=
(
rows-with-auto-pk
(
concat
parsed-rows
parsed-rows
))
(
rows-for-table
table
)))))
(
io/delete-file
file
)))))))
(
deftest
^
:mb/once
update-snowplow-test
(
mt/test-drivers
(
mt/normal-drivers-with-feature
:uploads
)
(
doseq
[
action
(
actions-to-test
driver/*driver*
)]
...
...
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