From 3d0400059b4d6b35a24ef565b899ab65afd46ced Mon Sep 17 00:00:00 2001 From: richelbilderbeek Date: Sat, 4 Jan 2025 21:39:31 +0100 Subject: [PATCH] Update tests due to https://github.com/ropensci/babette/issues/108 --- R/check_inference_model.R | 2 +- .../test-get_inference_model_filenames.R | 7 ++--- .../test-rename_inference_model_files.R | 27 ++++++++++++++----- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/R/check_inference_model.R b/R/check_inference_model.R index 65e99986..61f56941 100644 --- a/R/check_inference_model.R +++ b/R/check_inference_model.R @@ -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 '", diff --git a/tests/testthat/test-get_inference_model_filenames.R b/tests/testthat/test-get_inference_model_filenames.R index dc21b384..f4210958 100644 --- a/tests/testthat/test-get_inference_model_filenames.R +++ b/tests/testthat/test-get_inference_model_filenames.R @@ -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", { diff --git a/tests/testthat/test-rename_inference_model_files.R b/tests/testthat/test-rename_inference_model_files.R index 1e0c50f5..53c1c787 100644 --- a/tests/testthat/test-rename_inference_model_files.R +++ b/tests/testthat/test-rename_inference_model_files.R @@ -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, @@ -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", { @@ -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, @@ -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" + ) }) @@ -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, @@ -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", {