Skip to content

Commit

Permalink
test cases to check post_bug.R file
Browse files Browse the repository at this point in the history
  • Loading branch information
kpiyush04 committed Jul 5, 2021
1 parent bb7c1c0 commit 6481cd9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 39 deletions.
2 changes: 1 addition & 1 deletion R/post_bug.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ post_bug <- function(text, title, component, ...,
# Fill description, version and summary
if (missing(component)) {
cli::cli_alert("Please, pick a component:")
component <- menu(components)
component <- menu(components, graphics = TRUE)
}
component <- components[component]
version <- missing_version(version)
Expand Down
8 changes: 4 additions & 4 deletions R/post_help.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ read_documentation <- function() {
if (answer %in% no) {
cli::cli_alert_success("Opening documentation...")
lapply(official_documentation, browseURL)
stop("Do it and then return please.", call. = FALSE)
try(stop("Do it and then return please.", call. = FALSE))
}
invisible(answer == TRUE)
}
Expand All @@ -25,7 +25,7 @@ no <- c("Not sure", "Not now", "Negative", "No", "Nope", "Absolutely not")
ask_confirmation <- function(title = NULL, positive = yes, negative = no) {
options <- c(sample(positive, 1), sample(negative, 2)) # Mix which ones
options <- sample(options, 3) # Random order
sel <- menu(options, title = title)
sel <- menu(options, graphics = TRUE, title = title)
invisible(c("Cancel", options)[sel + 1])
}

Expand All @@ -38,8 +38,8 @@ ask_research <- function() {
cli::cli_alert("Are all the above questions affirmative?")
answer <- ask_confirmation()
if (answer %in% no) {
stop("Do it, later if you are still sure it is a bug then return please.",
call. = FALSE)
try(stop("Do it, later if you are still sure it is a bug then return please.",
call. = FALSE))
} else if (answer == "Cancel") {
return(invisible(NULL))
}
Expand Down
29 changes: 29 additions & 0 deletions tests/testthat/_snaps/post_bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# post_bug() works [plain]

Code
expect_equal(post_bug(), url)
Message <cliMessage>
> Please, pick a component:
Output
-- Documentation ---------------------------------------------------------------
Message <cliMessage>
> Have you read the documentation recently?
Output
(0 to cancel)
-- Previous research -----------------------------------------------------------
Message <cliMessage>
* Did you search for similar issues?
* Did you search on the mailing list archive?
* Did you search on forums and different sites?
> Are all the above questions affirmative?
-- Content of the issue --------------------------------------------------------
> Do you provide a short reproducible example of the issue?
Output
Maybe first check with the R-devel mailing list
Message <cliMessage>
> Is this issue about R and not a package?
> Do you explain expectations and the buggy behaviour?
> Did you try to identify the cause of the bug?
! This notification will reach the R-core volunteers and many more
* Are you sure to open a bug0 ?

7 changes: 7 additions & 0 deletions tests/testthat/test-post_bug.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cli::test_that_cli(configs = "plain", "post_bug() works", {
skip_if_not(interactive())
url <- paste0(missing_host(), "rest/bug")
expect_snapshot({
expect_equal(post_bug(), url)
})
})
34 changes: 0 additions & 34 deletions tests/testthat/test-post_help.R

This file was deleted.

0 comments on commit 6481cd9

Please sign in to comment.