Skip to content

Commit

Permalink
Update tests due to ropensci/babette#108
Browse files Browse the repository at this point in the history
  • Loading branch information
richelbilderbeek committed Jan 4, 2025
1 parent 8eb8b1c commit 3d04000
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion R/check_inference_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ check_inference_model <- function(
}
)
if (!is_one_na(inference_model$tipdates_filename)) {
check_string(inference_model$tipdates_filename)
check_string(inference_model$tipdates_filename, allow_na = TRUE)
if (!file.exists(inference_model$tipdates_filename)) {
stop(
"Tipdating filename not found at path '",
Expand Down
7 changes: 4 additions & 3 deletions tests/testthat/test-get_inference_model_filenames.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ test_that("use, all three filenames", {
inference_model$mcmc$tracelog$filename <- "/home/john/trace.log"
inference_model$mcmc$screenlog$filename <- "/home/john/screen.log"
inference_model$mcmc$treelog$filename <- "/home/john/tree.log"
inference_model$tipdates_filename <- "/home/john/tipdate.csv"
inference_model$tipdates_filename <- get_beautier_path(
"babette_issue_108_tipdates.txt"
)

filenames <- get_inference_model_filenames(inference_model)

expect_true("/home/john/trace.log" %in% filenames)
expect_true("/home/john/screen.log" %in% filenames)
expect_true("/home/john/tree.log" %in% filenames)
expect_true("/home/john/tipdate.csv" %in% filenames)

expect_true(inference_model$tipdates_filename %in% filenames)
})

test_that("no tipdates filename", {
Expand Down
27 changes: 21 additions & 6 deletions tests/testthat/test-rename_inference_model_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ test_that("replace dir from local to folder", {
inference_model$mcmc$tracelog$filename <- "trace.log"
inference_model$mcmc$screenlog$filename <- "screen.log"
inference_model$mcmc$treelog$filename <- "tree.log"
inference_model$tipdates_filename <- "tipdates.csv"
inference_model$tipdates_filename <- get_beautier_path(
"babette_issue_108_tipdates.txt"
)

inference_model <- rename_inference_model_filenames(
inference_model = inference_model,
Expand All @@ -16,7 +18,10 @@ test_that("replace dir from local to folder", {
inference_model$mcmc$screenlog$filename, "/home/john/screen.log"
)
expect_equal(inference_model$mcmc$treelog$filename, "/home/john/tree.log")
expect_equal(inference_model$tipdates_filename, "/home/john/tipdates.csv")
expect_equal(
inference_model$tipdates_filename,
"/home/john/babette_issue_108_tipdates.txt"
)
})

test_that("rename dir from folder to folder", {
Expand All @@ -25,7 +30,9 @@ test_that("rename dir from folder to folder", {
inference_model$mcmc$tracelog$filename <- "/home/john/trace.log"
inference_model$mcmc$screenlog$filename <- "/home/john/screen.log"
inference_model$mcmc$treelog$filename <- "/home/john/tree.log"
inference_model$tipdates_filename <- "/home/john/tipdates.csv"
inference_model$tipdates_filename <- get_beautier_path(
"babette_issue_108_tipdates.txt"
)

inference_model <- rename_inference_model_filenames(
inference_model = inference_model,
Expand All @@ -35,7 +42,10 @@ test_that("rename dir from folder to folder", {
expect_equal(inference_model$mcmc$tracelog$filename, "/home/doe/trace.log")
expect_equal(inference_model$mcmc$screenlog$filename, "/home/doe/screen.log")
expect_equal(inference_model$mcmc$treelog$filename, "/home/doe/tree.log")
expect_equal(inference_model$tipdates_filename, "/home/doe/tipdates.csv")
expect_equal(
inference_model$tipdates_filename,
"/home/doe/babette_issue_108_tipdates.txt"
)
})


Expand All @@ -45,7 +55,9 @@ test_that("remove dir", {
inference_model$mcmc$tracelog$filename <- "/home/john/trace.log"
inference_model$mcmc$screenlog$filename <- "/home/john/screen.log"
inference_model$mcmc$treelog$filename <- "/home/john/tree.log"
inference_model$tipdates_filename <- "/home/john/tipdates.csv"
inference_model$tipdates_filename <- get_beautier_path(
"babette_issue_108_tipdates.txt"
)

inference_model <- rename_inference_model_filenames(
inference_model = inference_model,
Expand All @@ -55,7 +67,10 @@ test_that("remove dir", {
expect_equal(inference_model$mcmc$tracelog$filename, "trace.log")
expect_equal(inference_model$mcmc$screenlog$filename, "screen.log")
expect_equal(inference_model$mcmc$treelog$filename, "tree.log")
expect_equal(inference_model$tipdates_filename, "tipdates.csv")
expect_equal(
inference_model$tipdates_filename,
"babette_issue_108_tipdates.txt"
)
})

test_that("use", {
Expand Down

0 comments on commit 3d04000

Please sign in to comment.