diff --git a/R/resolve.R b/R/resolve.R index 23bc0a0..698f315 100644 --- a/R/resolve.R +++ b/R/resolve.R @@ -85,15 +85,15 @@ bioc_version <- .query_biocver(snapshot_date) search_res <- .memo_search_bioc(bioc_version$version) search_res$pubdate <- anytime::anytime(bioc_version$date, tz = "UTC", asUTC = TRUE) - latest_version <- search_res[search_res$Package==handle,] - if (nrow(latest_version) == 0) { stop("No snapshot version exists for ", handle, ".", call. = FALSE) } pkg_dep_df <- .parse_desc(descr_df = latest_version,snapshot_date = snapshot_date) pkg_dep_df$x_bioc_ver <- bioc_version$version - pkg_dep_df <- pkg_dep_df[!is.na(pkg_dep_df$y),] + if ("y" %in% colnames(pkg_dep_df)) { + pkg_dep_df <- pkg_dep_df[!is.na(pkg_dep_df$y),] + } pkg_dep_df$x_pubdate <- bioc_version$date pkg_dep_df$x_pkgref <- .normalize_pkgs(handle,bioc_version = bioc_version$version) if("y"%in% names(pkg_dep_df)) { @@ -136,22 +136,21 @@ type <- lapply(seq_along(raw_deps), function(x) rep(types[x], length(raw_deps[[x]]))) version <- vapply(unlist(raw_deps), .extract_version, character(1), USE.NAMES = FALSE) deps <- gsub("\\s*\\(.*\\)","",unlist(raw_deps)) - if(length(deps) != 0) { - return(data.frame( - snapshot_date = snapshot_date, - x = descr_df[["Package"]], - x_version = descr_df[["Version"]], - y = deps, - type = unlist(type), - y_raw_version = unlist(version) - )) - } else { + if (length(deps) == 0 || all(is.na(deps))) { return(data.frame( snapshot_date = as.Date(snapshot_date), x = descr_df[["Package"]], x_version = descr_df[["Version"]] )) } + data.frame( + snapshot_date = snapshot_date, + x = descr_df[["Package"]], + x_version = descr_df[["Version"]], + y = deps, + type = unlist(type), + y_raw_version = unlist(version) + ) } # extract the required version, if present from description diff --git a/tests/testthat/test_resolve.R b/tests/testthat/test_resolve.R index 0043c20..b004f3f 100644 --- a/tests/testthat/test_resolve.R +++ b/tests/testthat/test_resolve.R @@ -194,3 +194,12 @@ test_that("issue 69, complete bioc information", { expect_equal(.normalize_pkg("affydata", "3.3"), "bioc::affydata") expect_equal(length(resolve("bioc::affydata", snapshot_date = "2016-06-15")$ranglets), 1) }) + +test_that("issue #82", { + skip_if_offline() + skip_on_cran() + expect_error(x <- .query_snapshot_dependencies_bioc("zlibbioc", "2023-01-01"), NA) + expect_false("y" %in% colnames(x)) + expect_error(x <- .query_snapshot_dependencies_bioc("Organism.dplyr", "2023-01-01"), NA) + expect_true("y" %in% colnames(x)) +})