Skip to content

Commit

Permalink
Add a test and move a test
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc committed Jul 23, 2024
1 parent 07fb37a commit 878a9c1
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions tests/testthat/test-release.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,37 @@ test_that("RStudio-ness detection works", {
)
})

test_that("can find milestone numbers", {
skip_if_offline("github.com")

tr <- list(
repo_owner = "r-lib",
repo_name = "usethis",
api_url = "https://api.github.com"
)

expect_equal(
gh_milestone_number(tr, "2.1.6", state = "all"),
8
)
expect_equal(
gh_milestone_number(tr, "0.0.0", state = "all"),
NA_integer_
)
})

test_that("gh_milestone_number() returns NA when gh() errors", {
local_mocked_bindings(
gh_tr = function(tr) { function(endpoint, ...) { ui_abort("nope!") } }
)
tr <- list(
repo_owner = "r-lib",
repo_name = "usethis",
api_url = "https://api.github.com"
)
expect_true(is.na(gh_milestone_number(tr, "1.1.1")))
})

# news --------------------------------------------------------------------

test_that("must have at least one heading", {
Expand Down Expand Up @@ -127,25 +158,6 @@ test_that("returns empty string if no bullets", {
expect_equal(news_latest(lines), "")
})

test_that("can find milestone numbers", {
skip_if_offline("github.com")

tr <- list(
repo_owner = "r-lib",
repo_name = "usethis",
api_url = "https://api.github.com"
)

expect_equal(
gh_milestone_number(tr, "2.1.6", state = "all"),
8
)
expect_equal(
gh_milestone_number(tr, "0.0.0", state = "all"),
NA_integer_
)
})

# draft release ----------------------------------------------------------------
test_that("get_release_data() works if no file found", {
skip_if_no_git_user()
Expand Down

0 comments on commit 878a9c1

Please sign in to comment.