Skip to content

Commit

Permalink
Adjust and test getting repos for whole hosts.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciekbanas committed Oct 17, 2024
1 parent 8484f15 commit b257b8b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
32 changes: 22 additions & 10 deletions R/GitHost.R
Original file line number Diff line number Diff line change
Expand Up @@ -720,16 +720,29 @@ GitHost <- R6::R6Class(
information = "Pulling repositories"
)
}
repos_response <- private$get_repos_response_with_code(
code = code,
in_files = in_files,
in_path = in_path,
output = output,
verbose = verbose,
progress = progress
)
rest_engine <- private$engines$rest
if (is.null(in_files)) {
repos_response <- rest_engine$get_repos_by_code(
code = code,
in_path = in_path,
output = output,
verbose = verbose,
progress = progress

Check warning on line 730 in R/GitHost.R

View check run for this annotation

Codecov / codecov/patch

R/GitHost.R#L725-L730

Added lines #L725 - L730 were not covered by tests
)
} else {
repos_response <- purrr::map(in_files, function(filename) {
rest_engine$get_repos_by_code(
code = code,
filename = filename,
in_path = in_path,
output = output,
verbose = verbose,
progress = progress
)
}) %>%
purrr::list_flatten()
}
if (output != "raw") {
rest_engine <- private$engines$rest
repos_table <- repos_response %>%
rest_engine$tailor_repos_response(
output = output

Check warning on line 748 in R/GitHost.R

View check run for this annotation

Codecov / codecov/patch

R/GitHost.R#L747-L748

Added lines #L747 - L748 were not covered by tests
Expand Down Expand Up @@ -792,7 +805,6 @@ GitHost <- R6::R6Class(
purrr::list_flatten()
}
if (output != "raw") {
rest_engine <- private$engines$rest
repos_table <- repos_response %>%
rest_engine$tailor_repos_response(
output = output
Expand Down
17 changes: 17 additions & 0 deletions tests/testthat/test-01-get_repos-GitHub.R
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,30 @@ test_that("`get_repos_with_code_from_orgs()` pulls raw response", {
)
repos_with_code_from_orgs_raw <- github_testhost_priv$get_repos_with_code_from_orgs(
code = "shiny",
in_files = c("DESCRIPTION", "NAMESPACE"),
output = "raw",
verbose = FALSE
)
expect_type(repos_with_code_from_orgs_raw, "list")
expect_gt(length(repos_with_code_from_orgs_raw), 0)
})

test_that("`get_repos_with_code_from_host()` pulls raw response", {
mockery::stub(
github_testhost_priv$get_repos_with_code_from_host,
"rest_engine$get_repos_by_code",
test_mocker$use("gh_repos_by_code_raw")
)
repos_with_code_from_host_raw <- github_testhost_priv$get_repos_with_code_from_host(
code = "shiny",
in_files = c("DESCRIPTION", "NAMESPACE"),
output = "raw",
verbose = FALSE
)
expect_type(repos_with_code_from_host_raw, "list")
expect_gt(length(repos_with_code_from_host_raw), 0)
})

test_that("get_repos_with_code() works", {
mockery::stub(
github_testhost_priv$get_repos_with_code,
Expand Down

0 comments on commit b257b8b

Please sign in to comment.