Skip to content

Commit a582817

Browse files
authored
Merge pull request #218 from r-lib/fix/tests
2 parents f391c2b + 8e7235c commit a582817

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

R/gh.R

+3
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ gh_make_request <- function(x, error_call = caller_env()) {
289289

290290
# Reduce connection timeout from curl's 10s default to 5s
291291
req <- httr2::req_options(req, connecttimeout_ms = 5000)
292+
if (Sys.getenv("GH_FORCE_HTTP_1_1") == "true") {
293+
req <- httr2::req_options(req, http_version = 2)
294+
}
292295

293296
if (!isFALSE(getOption("gh_cache"))) {
294297
req <- httr2::req_cache(

tests/testthat/setup.R

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
withr::local_options(
2+
gh_cache = FALSE,
3+
.local_envir = testthat::teardown_env()
4+
)

tests/testthat/test-gh_whoami.R

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ test_that("whoami works in presence of PAT", {
99
test_that("whoami errors with bad/absent PAT", {
1010
skip_if_no_github()
1111
skip_on_ci() # since no token sometimes fails due to rate-limiting
12+
withr::local_envvar(GH_FORCE_HTTP_1_1 = "true")
1213

1314
expect_snapshot(error = TRUE, {
1415
gh_whoami(.token = "")

tests/testthat/test-mock-repos.R

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ test_that("repos, some basics", {
1414
res <- gh(
1515
TMPL("/orgs/{org}/repos"),
1616
org = "r-lib",
17-
type = "sources"
17+
type = "sources",
18+
sort = "full_name"
1819
)
19-
expect_true("desc" %in% vapply(res, "[[", "name", FUN.VALUE = ""))
20+
expect_true("actions" %in% vapply(res, "[[", "name", FUN.VALUE = ""))
2021

2122
res <- gh("/repositories")
2223
expect_true(all(c("id", "name", "full_name") %in% names(res[[1]])))

0 commit comments

Comments
 (0)