Skip to content

Commit

Permalink
Update documentation and few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
llrs committed Apr 27, 2024
1 parent bb829f8 commit 7c19ed3
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 110 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
^_pkgdown\.yml$
^docs$
^pkgdown$

r_bugzilla.sql
mysql_rbugs.R
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Type: Package
Package: bugRzilla
Title: Interact with Bugzilla
Title: Interact with Bugzilla
Version: 0.0.90001
Authors@R:
person(given = "Lluís",
family = "Revilla Sancho",
role = c("aut", "cre", "cph"),
email = "lluis.revilla@gmail.com",
comment = c(ORCID = "0000-0001-9747-2570"))
Description: Provides data from bugzilla and allows to post.
Description: Uses the Bugzilla API to retrieve bug and allows to post.
License: GPL (>= 3)
URL: https://github.com/llrs/bugRzilla
BugReports: https://github.com/llrs/bugRzilla/issues
Expand All @@ -30,4 +30,4 @@ VignetteBuilder:
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
RoxygenNote: 7.3.1
3 changes: 1 addition & 2 deletions R/bugRzilla.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
#' Consider if this has been reported on the mailing list (R-devel) or on the
#' issue tracker itself.
#'
#' @docType package
#' @name bugRzilla
NULL
"_PACKAGE"
1 change: 1 addition & 0 deletions R/get_bug.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ get_bug <- function(issue, host) {
url <- paste0(host, "rest/bug?id=", issues)
bugs <- httr::GET(url, .state$headers)
httr::stop_for_status(bugs)

bugs <- httr::content(bugs)

if ("error" %in% names(bugs)) {
Expand Down
13 changes: 13 additions & 0 deletions man/bugRzilla.Rd

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

1 change: 1 addition & 0 deletions tests/fixtures/get_fields.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/fixtures/get_history.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"http_interactions":[{"request":{"method":"get","uri":"https://bugs.r-project.org/rest/bug/1/history","body":{"encoding":"","string":""},"headers":{"Accept":"application/json, text/xml, application/xml, */*","X-BUGZILLA-API-KEY":"Removing this header too just in case","User-Agent":"https://github.com/llrs/bugRzilla/"}},"response":{"status":{"status_code":400,"category":"Client error","reason":"Bad Request","message":"Client error: (400) Bad Request"},"headers":{"server":"nginx","date":"Sat, 27 Apr 2024 09:48:09 GMT","content-type":"application/json; charset=UTF-8","content-length":"185","etag":"1oNltT0syPlwGjTgxxVL6g","access-control-allow-headers":"accept, content-type, origin, user-agent, x-requested-with, x-bugzilla-password, x-bugzilla-api-key, x-bugzilla-login, x-bugzilla-token","access-control-allow-origin":"*","content-security-policy":"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'","x-content-security-policy":"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'","x-content-type-options":"nosniff","x-frame-options":"SAMEORIGIN","x-webkit-csp":"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'","x-xss-protection":"1; mode=block"},"body":{"encoding":"","file":false,"string":"{\"code\":\"306\",\"message\":\"The API key you specified is invalid. Please check that you typed it correctly.\",\"documentation\":\"https://bugzilla.readthedocs.org/en/latest/api/\",\"error\":true}"}},"recorded_at":"2024-04-27 09:48:09 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]}
1 change: 1 addition & 0 deletions tests/fixtures/get_history_fails.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"http_interactions":[{"request":{"method":"get","uri":"https://bugs.r-project.org/rest/bug/2/history","body":{"encoding":"","string":""},"headers":{"Accept":"application/json, text/xml, application/xml, */*","X-BUGZILLA-API-KEY":"Removing this header too just in case","User-Agent":"https://github.com/llrs/bugRzilla/"}},"response":{"status":{"status_code":400,"category":"Client error","reason":"Bad Request","message":"Client error: (400) Bad Request"},"headers":{"server":"nginx","date":"Sat, 27 Apr 2024 09:48:10 GMT","content-type":"application/json; charset=UTF-8","content-length":"185","etag":"1oNltT0syPlwGjTgxxVL6g","access-control-allow-headers":"accept, content-type, origin, user-agent, x-requested-with, x-bugzilla-login, x-bugzilla-token, x-bugzilla-api-key, x-bugzilla-password","access-control-allow-origin":"*","content-security-policy":"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'","x-content-security-policy":"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'","x-content-type-options":"nosniff","x-frame-options":"SAMEORIGIN","x-webkit-csp":"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'","x-xss-protection":"1; mode=block"},"body":{"encoding":"","file":false,"string":"{\"code\":\"306\",\"message\":\"The API key you specified is invalid. Please check that you typed it correctly.\",\"documentation\":\"https://bugzilla.readthedocs.org/en/latest/api/\",\"error\":true}"}},"recorded_at":"2024-04-27 09:48:10 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]}
16 changes: 8 additions & 8 deletions tests/testthat/_snaps/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@

Code
create_bugzilla_key()
Message <cliMessage>
Message
i Reading cached keys on '~/.cache/R/bugRzilla/.Renviron'.
v Found key `R_BUGZILLA`.
v Using key `R_BUGZILLA`.
v Authenticated on this site!
x Not authenticated on this site.

# create_bugzilla_key() works [unicode]

Code
create_bugzilla_key()
Message <cliMessage>
Message
ℹ Reading cached keys on '~/.cache/R/bugRzilla/.Renviron'.
✔ Found key `R_BUGZILLA`.
✔ Using key `R_BUGZILLA`.
✔ Authenticated on this site!
✖ Not authenticated on this site.

# set_key works

Code
sk <- set_key()
Message <cliMessage>
Message
i Reading cached keys on '~/.cache/R/bugRzilla/.Renviron'.
v Found key `R_BUGZILLA`.
v Using key `R_BUGZILLA`.
Code
expect_equal(write_renviron(key = sk, value = sk, file = app_file()), NULL)
Message <cliMessage>
Message
v Storing key on '~/.cache/R/bugRzilla/.Renviron'.

# check_key() works [plain]
Expand All @@ -49,14 +49,14 @@

Code
use_key(missing_key())
Message <cliMessage>
Message
v Using key `R_BUGZILLA`.

# use_key() works [unicode]

Code
use_key(missing_key())
Message <cliMessage>
Message
✔ Using key `R_BUGZILLA`.

# valid_key() works [plain]
Expand Down
86 changes: 0 additions & 86 deletions tests/testthat/_snaps/api.new.md

This file was deleted.

4 changes: 2 additions & 2 deletions tests/testthat/_snaps/get_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

Code
use_key()
Message <cliMessage>
Message
v Using key `R_BUGZILLA`.

# get_user multiple ids

Code
use_key()
Message <cliMessage>
Message
v Using key `R_BUGZILLA`.

2 changes: 1 addition & 1 deletion tests/testthat/helper-vcr.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (!nzchar(Sys.getenv("R_BUGZILLA"))) {
}
}

use_key()
use_key("R_BUGZILLA")

invisible(vcr::vcr_configure(
dir = vcr_dir,
Expand Down
18 changes: 10 additions & 8 deletions tests/testthat/test-post_comment.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
test_that("post_comment works", {
vcr::use_cassette("post_comment", {
pc <- post_comment(issue = 1, comment = "testing",
host = "https://rbugs-devel.urbanek.info/",
key = "R_DEV_BUGZILLA")
})
expect_true(is.numeric(pc))

})
# Website is no longer available
# test_that("post_comment works", {
# vcr::use_cassette("post_comment", {
# pc <- post_comment(issue = 1, comment = "testing",
# host = "https://rbugs-devel.urbanek.info/",
# key = "R_DEV_BUGZILLA")
# })
# expect_true(is.numeric(pc))
#
# })

0 comments on commit 7c19ed3

Please sign in to comment.