Skip to content

Commit

Permalink
get_imports now correctly handles return from api
Browse files Browse the repository at this point in the history
  • Loading branch information
b-rodrigues committed Jan 9, 2025
1 parent 6a09605 commit 8bb5bcc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 3 additions & 1 deletion R/fetchers.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ fetchgit <- function(git_pkg) {
remotes
)

if (is.null(remotes)) { # if no remote dependencies
if (is.null(remotes) | (is.list(remotes) & length(remotes) == 0)) {
# if no remote dependencies: can be NULL if nix_hash runs locally
# but will be empty list if nix_hash runs on the api

output <- main_package_expression
} else { # if there are remote dependencies, start over
Expand Down
34 changes: 33 additions & 1 deletion tests/testthat/test-get_sri_hash_deps.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
testthat::test_that("get_sri_hash_deps returns correct sri hash and dependencies of R packages", {
testthat::test_that("get_sri_hash_deps returns correct sri hash and dependencies of R packages, locally", {

# only run this one locally
skip_if_not(nix_shell_available())

testthat::skip_on_cran()

testthat::expect_equal(
get_sri_hash_deps(
"https://github.com/rap4all/housing/",
"1c860959310b80e67c41f7bbdc3e84cef00df18e"
),
list(
"sri_hash" = "sha256-s4KGtfKQ7hL0sfDhGb4BpBpspfefBN6hf+XlslqyEn4=",
"deps" = list(
"package" = "housing",
"imports" = c(
"dplyr", "ggplot2", "janitor", "purrr",
"readxl", "rlang", "rvest", "stringr", "tidyr"
),
"remotes" = NULL
)
)
)
})

testthat::test_that("get_sri_hash_deps returns correct sri hash and dependencies of R packages, online", {

# only run this one if the shell is not available, running it through the api
!skip_if_not(nix_shell_available())

testthat::skip_on_cran()

testthat::expect_equal(
get_sri_hash_deps(
"https://github.com/rap4all/housing/",
Expand Down

0 comments on commit 8bb5bcc

Please sign in to comment.