32.4 Settings
- A generic settings can be found in the
PEcAn.all
package
<- system.file("pecan.biocro.xml", package = "PEcAn.BIOCRO")
settings.xml <- read.settings(settings.xml) settings
- database settings can be specified, and tests run only if a connection is available
We currently use the following database to run tests against; tests that require access to a database should check db.exists()
and be skipped if it returns FALSE to avoid failed tests on systems that do not have the database installed.
$database <- list(userid = "bety",
settingspasswd = "bety",
name = "bety", # database name
host = "localhost" # server name)
test_that(..., {
skip_if_not(db.exists(settings$database))
## write tests here
})
instructions for installing this are available on the VM creation wiki
examples can be found in the PEcAn.DB package (
base/db/tests/testthat/
).Model specific settings can go in the model-specific module, for example:
<- system.file("extdata/pecan.biocro.xml", package = "PEcAn.BIOCRO")
settings.xml <- read.settings(settings.xml) settings
- test-specific settings:
settings text can be specified inline:
settings.text <- " <pecan> <nocheck>nope</nocheck> ## allows bypass of checks in the read.settings functions <pfts> <pft> <name>ebifarm.pavi</name> <outdir>test/</outdir> </pft> </pfts> <outdir>test/</outdir> <database> <userid>bety</userid> <passwd>bety</passwd> <location>localhost</location> <name>bety</name> </database> </pecan>" settings <- read.settings(settings.text)
values in settings can be updated:
<- read.settings(settings.text) settings $outdir <- "/tmp" ## or any other settings settings