From 51be25287da855ebace3d4bf8568ba443d796081 Mon Sep 17 00:00:00 2001 From: Maciej Nasinski Date: Fri, 27 Sep 2024 20:38:23 +0200 Subject: [PATCH] make a fix --- R/deps_timemachine.R | 6 ++++-- tests/testthat/test-deps.R | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/R/deps_timemachine.R b/R/deps_timemachine.R index 94d3fa3..62fd73b 100644 --- a/R/deps_timemachine.R +++ b/R/deps_timemachine.R @@ -69,8 +69,10 @@ pac_deps_timemachine <- function(pac, # not care about many versions for certain apckage as we taking the newset version if (isTRUE(r != "R" && r != pac && (!r %in% paks_global))) { pks <- pac_description(r, at = at, local = FALSE) - paks_global <<- c(stats::setNames(r, pks$Version), paks_global[paks_global != r]) - if (recursive) deps(r, at, pks[fields]) + if (is.list(pks)) { + paks_global <<- c(stats::setNames(r, pks$Version), paks_global[paks_global != r]) + if (recursive) deps(r, at, pks[fields]) + } } } } diff --git a/tests/testthat/test-deps.R b/tests/testthat/test-deps.R index 23ea308..f656593 100644 --- a/tests/testthat/test-deps.R +++ b/tests/testthat/test-deps.R @@ -86,8 +86,9 @@ test_that("pacs::pac_deps_timemachine", { skip_if_offline() expect_message(pac_deps_timemachine("WRONG", "0.8.0"), "WRONG package is not on CRAN") expect_identical(suppressMessages(pac_deps_timemachine("WRONG", "0.8.0")), NA) - expect_true(length(pac_deps_timemachine("memoise", "0.2.1")) == 1) - expect_true(length(pac_deps_timemachine("memoise", at = as.Date("2019-01-01"))) == 1) + expect_length(pac_deps_timemachine("memoise", "0.2.1"), 1) + expect_length(pac_deps_timemachine("memoise", at = as.Date("2019-01-01")), 1) + expect_length(pacs::pac_deps_timemachine("ggplot2", at = as.Date("2020-10-10")), 42) }) test_that("pacs::pac_deps_timemachine offline", {