Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions R/post_bug.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ components <- c("Accuracy", "Add-ons", "Analyses", "Documentation", "Graphics",
#'
#' Guides through the process of creating an issue.
#' Requires an user and an API key.
#' @param text A character vector with the text of the bug you want to
#' open.
# #' @param text A character vector with the text of the bug you want to
# #' open.
Comment thread
kpiyush04 marked this conversation as resolved.
Outdated
#' @param title A character vector with the title of the bug.
#' @param component A character with the component of R you want to fill an issue with.
#' @param version A character of the Version you want to use eg "R 4.0.0".
Expand All @@ -23,9 +23,10 @@ components <- c("Accuracy", "Add-ons", "Analyses", "Documentation", "Graphics",
#' @seealso To obtain and use the API key see create_bugzilla_key().
#' [Webpage](https://bugs.r-project.org/bugzilla/enter_bug.cgi) for manual entry
#' @return The ID of the issue posted.
post_bug <- function(text, title, component, ...,
version, product, host, key) {
post_bug <- function(title, component, ...,
version, product, host, key) {
# Provide some checks/questions to the users
title <- readline(prompt = "Bug Title: ")
Comment thread
kpiyush04 marked this conversation as resolved.
Outdated
# Fill description, version and summary
if (missing(component)) {
cli::cli_alert("Please, pick a component:")
Expand All @@ -45,14 +46,14 @@ post_bug <- function(text, title, component, ...,
return()
}
ask_final_confirmation()
url <- paste0(host, "rest/bug")
# bugs <- httr::POST(url,
# description = text,
# product = product,
# component = component,
# summary = title,
# version = version,
# ...,
# headers)
# bugs <- httr::content(bugs)
url <- paste0(host, "rest/bug?")
data <- list(
product = product,
component = component,
version = version,
summary = title
)
bugs <- httr::POST(url, body = data, encode = "json")
Comment thread
kpiyush04 marked this conversation as resolved.
Outdated
bugs <- httr::content(bugs)
print(bugs)
Comment thread
kpiyush04 marked this conversation as resolved.
Outdated
}
5 changes: 1 addition & 4 deletions man/post_bug.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions tests/fixtures/post_bug_works.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
http_interactions:
- request:
method: post
uri: https://bugs.r-project.org/bugzilla/rest/bug
body:
encoding: ''
string: '{"product":"R","component":"Misc","version":"4.0.x","summary":"test!!!"}'
headers:
Accept: application/json, text/xml, application/xml, */*
Content-Type: application/json
response:
status:
status_code: 401
category: Client error
reason: Unauthorized
message: 'Client error: (401) Unauthorized'
headers:
date: Thu, 15 Jul 2021 17:00:35 GMT
server: gazelle
etag: 8hv3qhJNknTVRt2cjTD2dw
content-length: '157'
content-type: application/json; charset=UTF-8
access-control-allow-headers: accept, content-type, origin, user-agent, x-requested-with,
x-bugzilla-api-key, x-bugzilla-password, x-bugzilla-token, x-bugzilla-login
access-control-allow-origin: '*'
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
body:
encoding: UTF-8
file: no
string: '{"code":"410","message":"You must log in before using this part of
Bugzilla.","error":true,"documentation":"https://bugzilla.readthedocs.org/en/latest/api/"}'
recorded_at: 2021-07-15 17:00:35 GMT
recorded_with: vcr/1.0.2, webmockr/0.8.0
5 changes: 5 additions & 0 deletions tests/testthat/_snaps/post_bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# post_bug() works [plain]

Code
expect_type(pg, "list")

18 changes: 18 additions & 0 deletions tests/testthat/test-post_bug.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cli::test_that_cli(configs = "plain", "post_bug() works", {
skip_if_not(interactive())
vcr::use_cassette("post_bug_works", {
pg <- post_bug()
})
expect_snapshot(
expect_type(pg, "list")
)
})


# cli::test_that_cli(configs = "plain", "post_bug() fails", {
# skip_if_not(interactive())
# pg1 <- post_bug()
# expect_snapshot(
# expect_error(pg1, "Do it and then return please.")
Comment thread
kpiyush04 marked this conversation as resolved.
Outdated
# )
# })