Skip to content

Commit

Permalink
skip GH tests if rate limit insufficient
Browse files Browse the repository at this point in the history
  • Loading branch information
ErdaradunGaztea committed Apr 10, 2024
1 parent e6e7eb9 commit fcb0f66
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/testthat/setup-limits.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
over_gh_limit <- function(num_necessary = 1) {
limit <- httr2::request("https://api.github.com") |>
httr2::req_url_path_append("rate_limit") |>
httr2::req_perform() |>
httr2::resp_body_json()
limit$resources$core$remaining < num_necessary
}
1 change: 1 addition & 0 deletions tests/testthat/test-github-dependencies.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
skip_if_not_installed("httptest2")
skip_if(over_gh_limit(), "Github rate limit not sufficient")
wood_clear_cache()

# SETUP ----
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-github-latest.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
skip_if_not_installed("httptest2")
skip_if(over_gh_limit(), "Github rate limit not sufficient")
wood_clear_cache()

# SETUP ----
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-github-packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ skip_if_not_installed("httptest2")
# 1. Mocked responses form too long paths even if fully compressed
# 2. turtletopia/.github repository is treated as a hidden directory, an it's not allowed there
skip_if_offline()
skip_if(over_gh_limit(), "Github rate limit not sufficient")
wood_clear_cache()

# SETUP ----
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-github-tags.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
skip_if_not_installed("httptest2")
skip_if(over_gh_limit(), "Github rate limit not sufficient")
wood_clear_cache()

# SETUP ----
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-github-versions.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
skip_if_not_installed("httptest2")
skip_if(over_gh_limit(), "Github rate limit not sufficient")
wood_clear_cache()

# SETUP ----
Expand Down

0 comments on commit fcb0f66

Please sign in to comment.