Skip to content

Commit

Permalink
Test-cover case when there are no default tokens.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciekbanas committed Oct 15, 2024
1 parent d8a771d commit c9703ec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/testthat/_snaps/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@
Message
i Using PAT from GITHUB_PAT envar.

# `set_default_token` returns error if none are found

Code
github_testhost_priv$set_default_token(verbose = TRUE)
Condition
Error:
x No sufficient token found among: [GITHUB_PAT, GITHUB_PAT_INSUFFICIENT, GITHUB_PAT_MIN, GITHUB_PAT_ROCHE, TEST_GITHUB_PAT].
i Check if you have correct token.
! Scope that is needed: [public_repo, read:org, read:user].

# `set_default_token` sets default token for GitLab

Code
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,19 @@ test_that("`set_default_token` sets default token for public GitHub", {
)
})

test_that("`set_default_token` returns error if none are found", {
mockery::stub(
github_testhost_priv$set_default_token,
"private$test_token",
FALSE
)
expect_snapshot({
github_testhost_priv$set_default_token(
verbose = TRUE
)
}, error = TRUE)
})

test_that("`test_token` works properly", {
skip_on_cran()
expect_true(
Expand Down

0 comments on commit c9703ec

Please sign in to comment.