Skip to content
Snippets Groups Projects
Commit 1a487316 authored by cedricbriandgithub's avatar cedricbriandgithub
Browse files

Merge branch '0.6.1.9000' of forgemia.inra.fr:stacomi/stacomir into 0.6.1.9000

parents 2ad72da4 7a9984d5
No related branches found
No related tags found
No related merge requests found
Pipeline #298927 failed
......@@ -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
......
......@@ -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.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment