Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
collectr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
DREAL Pays de la Loire
Centre de Services de la Donnée
ADL
collectr
Commits
729cee9e
Commit
729cee9e
authored
4 months ago
by
ronan.vignard
Browse files
Options
Downloads
Patches
Plain Diff
Création des tests pour insert_into_table()
parent
056ac042
No related branches found
No related tags found
4 merge requests
!67
Passage en version 0.1.6
,
!66
Intégration de la fonction download_files_from_list()
,
!65
Correction d'un bug + création des tests pour fix_encoding_variable()
,
!64
Création des tests pour insert_into_table()
Pipeline
#537536
passed
4 months ago
Stage: build
Stage: test
Stage: pkgdown
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dev/0-dev_history.Rmd
+2
-0
2 additions, 0 deletions
dev/0-dev_history.Rmd
tests/testthat/test-insert_into_table.R
+47
-0
47 additions, 0 deletions
tests/testthat/test-insert_into_table.R
with
49 additions
and
0 deletions
dev/0-dev_history.Rmd
+
2
−
0
View file @
729cee9e
...
@@ -87,6 +87,7 @@ usethis::use_r("import_and_merge_tables")
...
@@ -87,6 +87,7 @@ usethis::use_r("import_and_merge_tables")
usethis::use_r("import_geopackage")
usethis::use_r("import_geopackage")
usethis::use_r("import_shapefile")
usethis::use_r("import_shapefile")
usethis::use_r("import_xlsx")
usethis::use_r("import_xlsx")
usethis::use_r("insert_into_table")
usethis::use_r("modify_column_type")
usethis::use_r("modify_column_type")
usethis::use_r("remove_special_chars")
usethis::use_r("remove_special_chars")
usethis::use_r("rename_field")
usethis::use_r("rename_field")
...
@@ -110,6 +111,7 @@ usethis::use_test("import_and_merge_tables")
...
@@ -110,6 +111,7 @@ usethis::use_test("import_and_merge_tables")
usethis::use_test("import_geopackage")
usethis::use_test("import_geopackage")
usethis::use_test("import_shapefile")
usethis::use_test("import_shapefile")
usethis::use_test("import_xlsx")
usethis::use_test("import_xlsx")
usethis::use_test("insert_into_table")
usethis::use_test("modify_column_type")
usethis::use_test("modify_column_type")
usethis::use_test("remove_special_chars")
usethis::use_test("remove_special_chars")
usethis::use_test("rename_field")
usethis::use_test("rename_field")
...
...
This diff is collapsed.
Click to expand it.
tests/testthat/test-insert_into_table.R
0 → 100644
+
47
−
0
View file @
729cee9e
test_that
(
"insert_into_table works"
,
{
Sys.setenv
(
user_runner
=
"runner"
)
Sys.setenv
(
pwd_runner
=
Sys.getenv
(
"BDD_RUNNER_PWD"
))
# Création d'un dataframe fictif
source
<-
data.frame
(
id
=
6
:
10
,
name
=
c
(
"Alice"
,
"Bob"
,
"Charlie"
,
"David"
,
"Eve"
),
birthdate
=
c
(
"1990-01-15"
,
"1985-06-22"
,
"1992-09-10"
,
"1988-03-05"
,
"1995-12-30"
),
value
=
rnorm
(
5
)
)
# Créer une table target dans le schéma public de la base collectr
create_dummy
(
host
=
"localhost"
,
database
=
"collectr"
,
schema
=
"public"
,
table
=
"target"
,
pk
=
"id"
,
id_range
=
"1:5"
,
role
=
"runner"
)
expect_equal
(
object
=
insert_into_table
(
host
=
"localhost"
,
database
=
"collectr"
,
schema
=
"public"
,
table
=
"target"
,
dataframe
=
source
,
role
=
"runner"
),
expected
=
5
)
expect_error
(
object
=
insert_into_table
(
host
=
"localhost"
,
database
=
"collectr"
,
schema
=
"public"
,
table
=
"ghost"
,
dataframe
=
source
,
role
=
"runner"
),
regexp
=
"La table sp\u00e9cifi\u00e9e n\'existe pas dans la base de donn\u00e9es."
)
# Création d'un dataframe avec une structure différente de la table
df
<-
data.frame
(
id
=
1
:
5
,
name
=
letters
[
1
:
5
],
value
=
rnorm
(
5
))
# Créer une table target dans le schéma public de la base collectr
create_dummy
(
host
=
"localhost"
,
database
=
"collectr"
,
schema
=
"public"
,
table
=
"target"
,
pk
=
"id"
,
id_range
=
"1:5"
,
role
=
"runner"
)
expect_false
(
insert_into_table
(
host
=
"localhost"
,
database
=
"collectr"
,
schema
=
"public"
,
table
=
"target"
,
dataframe
=
df
,
role
=
"runner"
))
})
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