Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jordan S Read
committed
Mar 27, 2016
1 parent
88fcb20
commit 660eeaf
Showing
4 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
context("convert variables in netcdf output") | ||
|
||
test_that("errors with poor matches", { | ||
sim_folder <- run_example_sim(verbose = FALSE) | ||
nc_file <<- file.path(sim_folder, 'output.nc') | ||
expect_error(convert_sim_var(nc_file, temp = temp*2), "temp cannot be added, it already exists.") | ||
expect_error(convert_sim_var(nc_file, temp.new = garbage), "garbage do not exist in simulation vars") | ||
}) | ||
|
||
test_that("can add variable", { | ||
convert_sim_var(nc_file, temp.new = temp*2) | ||
expect_true('temp.new' %in% sim_vars(nc_file)$name) | ||
expect_is(get_var(nc_file, var_name = 'temp.new'), 'data.frame') | ||
}) | ||
|
||
test_that("errors when you try to add it again", { | ||
expect_error(convert_sim_var(nc_file, temp.new = temp*2)) | ||
}) | ||
|
||
test_that("can modify variable with more than one variable function", { | ||
|
||
convert_sim_var(nc_file, crazy_var = temp-u_mean*1000) | ||
expect_true('crazy_var' %in% sim_vars(nc_file)$name) | ||
}) |