Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
stacomiR
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
Stacomi
stacomiR
Commits
7a9984d5
Commit
7a9984d5
authored
2 weeks ago
by
Laurent BEAULATON
Browse files
Options
Downloads
Patches
Plain Diff
fix: stacomi_test user and "All foreign keys are present"
parent
6558a7eb
No related branches found
No related tags found
No related merge requests found
Pipeline
#298925
failed
2 weeks ago
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dev/03_deploy.R
+3
-10
3 additions, 10 deletions
dev/03_deploy.R
tests/testthat/helper.R
+38
-49
38 additions, 49 deletions
tests/testthat/helper.R
tests/testthat/test-00-stacomir.R
+235
-216
235 additions, 216 deletions
tests/testthat/test-00-stacomir.R
with
276 additions
and
275 deletions
dev/03_deploy.R
+
3
−
10
View file @
7a9984d5
...
...
@@ -13,17 +13,10 @@
# setwd("C:\\workspace\\stacomir")
# Test your app
# options("stacomiR.printqueries"=TRUE)
rm
(
list
=
ls
(
all.names
=
TRUE
))
#formatR::tidy_dir(path="/inst/examples")
devtools
::
load_all
()
rm
(
list
=
ls
(
all.names
=
TRUE
))
#
formatR::tidy_dir(path="/inst/examples")
devtools
::
load_all
()
Sys.setenv
(
"LANGUAGE"
=
"en"
)
# otherwise problems when running from Rstudio
options
(
stacomiR.dbname
=
"bd_contmig_nat_test"
,
stacomiR.host
=
"localhost"
,
stacomiR.port
=
"5432"
,
stacomiR.user
=
"test"
,
stacomiR.password
=
"test"
)
# GO TO helper.R called before everything to change options.
devtools
::
test
()
# this will run load_all() see details about classes below for specific tests
...
...
This diff is collapsed.
Click to expand it.
tests/testthat/helper.R
+
38
−
49
View file @
7a9984d5
...
...
@@ -3,63 +3,52 @@
# this file is called before testhat so funcion will be available in all test
# https://testthat.r-lib.org/articles/test-fixtures.html#withr-defer-
# could have used with_envvar and local_envvar but had to set them each time
#
options(
#
stacomiR.dbname = "bd_contmig_nat
_test
",
#
stacomiR.host ="localhost",
#
stacomiR.port = "5432",
#
stacomiR.user = "test",
#
stacomiR.password = "test"
#
)
options
(
stacomiR.dbname
=
"bd_contmig_nat"
,
stacomiR.host
=
"localhost"
,
stacomiR.port
=
"5432"
,
stacomiR.user
=
"
stacomi_
test"
,
stacomiR.password
=
"
stacomi_
test"
)
password
<-
getOption
(
"stacomiR.password"
)
#if not set will be ""
dbname
<-
getOption
(
"stacomiR.dbname"
)
#if not set will be ""
user
<-
getOption
(
"stacomiR.user"
)
host
<-
getOption
(
"stacomiR.host"
)
port
<-
getOption
(
"stacomiR.port"
)
if
(
user
==
""
){
user
<-
"postgres"
if
(
user
==
""
)
{
user
<-
"postgres"
}
if
(
password
==
""
){
password
<-
"postgres"
if
(
password
==
""
)
{
password
<-
"postgres"
}
#options(
# stacomiR.dbname = dbname,
# stacomiR.host = host,
# stacomiR.port = port,
# stacomiR.user = user,
# stacomiR.password = password
#)
env_set_test_stacomi
<-
function
(
env
=
parent.frame
())
{
password
<-
getOption
(
"stacomiR.password"
)
#if not set will be ""
dbname
<-
getOption
(
"stacomiR.dbname"
)
#if not set will be ""
user
<-
getOption
(
"stacomiR.user"
)
host
<-
getOption
(
"stacomiR.host"
)
port
<-
getOption
(
"stacomiR.port"
)
env_set_test_stacomi
<-
function
(
env
=
parent.frame
())
{
password
<-
getOption
(
"stacomiR.password"
)
# if not set will be ""
dbname
<-
getOption
(
"stacomiR.dbname"
)
# if not set will be ""
user
<-
getOption
(
"stacomiR.user"
)
host
<-
getOption
(
"stacomiR.host"
)
port
<-
getOption
(
"stacomiR.port"
)
if
(
user
==
""
){
user
<-
"postgres"
}
if
(
password
==
""
){
password
<-
"postgres"
}
# defer untill the parent env has closed to reset values after test
# withr::defer(options(
# stacomiR.dbname = dbname,
# stacomiR.host = host,
# stacomiR.port = port,
# stacomiR.user = user,
# stacomiR.password = password
# ), env)
assign
(
"user"
,
user
,
envir
=
env
)
assign
(
"password"
,
password
,
envir
=
env
)
assign
(
"host"
,
host
,
envir
=
env
)
assign
(
"schema"
,
"test"
,
envir
=
env
)
# test for foreign keys in the database ? set TRUE to test FALSE to avoid tests
# if set to TRUE be sure that user and password correspond to superuser
assign
(
"test_foreign_keys"
,
TRUE
,
envir
=
env
)
if
(
user
==
""
)
{
user
<-
"postgres"
}
if
(
password
==
""
)
{
password
<-
"postgres"
}
# defer untill the parent env has closed to reset values after test
# withr::defer(options(
# stacomiR.dbname = dbname,
# stacomiR.host = host,
# stacomiR.port = port,
# stacomiR.user = user,
# stacomiR.password = password
# ), env)
assign
(
"user"
,
user
,
envir
=
env
)
assign
(
"password"
,
password
,
envir
=
env
)
assign
(
"host"
,
host
,
envir
=
env
)
assign
(
"schema"
,
"test"
,
envir
=
env
)
# test for foreign keys in the database ? set TRUE to test FALSE to avoid tests
# if set to TRUE be sure that user and password correspond to superuser
assign
(
"test_foreign_keys"
,
TRUE
,
envir
=
env
)
}
This diff is collapsed.
Click to expand it.
tests/testthat/test-00-stacomir.R
+
235
−
216
View file @
7a9984d5
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