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
3738b5f6
Commit
3738b5f6
authored
4 months ago
by
ronan.vignard
Browse files
Options
Downloads
Patches
Plain Diff
Création des tests pour la fonction
parent
f710c50a
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!55
Création des tests pour import_shapefile()
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/testthat/test-modify_column_type.R
+46
-0
46 additions, 0 deletions
tests/testthat/test-modify_column_type.R
with
46 additions
and
0 deletions
tests/testthat/test-modify_column_type.R
0 → 100644
+
46
−
0
View file @
3738b5f6
test_that
(
"modify_column_type works"
,
{
Sys.setenv
(
user_runner
=
"runner"
)
Sys.setenv
(
pwd_runner
=
Sys.getenv
(
"BDD_RUNNER_PWD"
))
# Création d'une table dummy
create_dummy
(
host
=
"localhost"
,
database
=
"collectr"
,
schema
=
"public"
,
table
=
"dummy"
,
role
=
"runner"
)
# Vérification que la fonction retourne TRUE si le changement de type fonctionne
expect_equal
(
object
=
modify_column_type
(
host
=
"localhost"
,
database
=
"collectr"
,
schema
=
"public"
,
table
=
"dummy"
,
column_name
=
"birthdate"
,
column_type
=
"date"
,
role
=
"runner"
),
expected
=
TRUE
)
# Vérification du message retourné en cas d'absence de la table à modifier
expect_message
(
object
=
table_exists
(
host
=
"localhost"
,
database
=
"collectr"
,
schema
=
"public"
,
table
=
"ghost"
,
role
=
"runner"
),
message
=
"La table sp\u00e9cifi\u00e9e n\'existe pas dans la base de donn\u00e9es."
)
})
test_that
(
"modify_column_type fails"
,
{
skip_on_ci
()
# Simulation d'une connexion invalide (NULL ou autre type)
fake_connexion
<-
list
()
# Une liste vide ne correspond pas à un objet PostgreSQLConnection
# Mock de la fonction connect_to_db pour retourner une connexion invalide
mockery
::
stub
(
modify_column_type
,
"datalibaba::connect_to_db"
,
fake_connexion
)
# Vérification que la fonction génère bien une erreur sur la connexion invalide
expect_error
(
modify_column_type
(
database
,
schema
,
table
,
column_name
,
column_type
,
role
),
"La connexion fournie n\'est pas une connexion PostgreSQL valide."
)
})
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