-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check api functions to increase Code Coverage (#6)
- Loading branch information
Showing
6 changed files
with
202 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
http_interactions: | ||
- request: | ||
method: get | ||
uri: https://bugs.r-project.org/bugzilla/rest/last_audit_time | ||
body: | ||
encoding: '' | ||
string: '' | ||
headers: | ||
Accept: application/json, text/xml, application/xml, */* | ||
Authorization: My bearer token is safe | ||
X-BUGZILLA-API-KEY: Removing this header too just in case | ||
response: | ||
status: | ||
status_code: 200 | ||
category: Success | ||
reason: OK | ||
message: 'Success: (200) OK' | ||
headers: | ||
date: Fri, 18 Jun 2021 20:57:31 GMT | ||
server: gazelle | ||
etag: nuyzry+9UExbGXwyRTkrfQ | ||
content-length: '42' | ||
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-login, x-bugzilla-token, x-bugzilla-password | ||
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: '{"last_audit_time":"2021-06-18T20:47:32Z"}' | ||
recorded_at: 2021-06-18 20:57:31 GMT | ||
recorded_with: vcr/0.6.0, webmockr/0.8.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# create_bugzilla_key() works [plain] | ||
|
||
Code | ||
create_bugzilla_key() | ||
Message <cliMessage> | ||
i Reading cached keys on '/home/data/.cache/R/bugRzilla/.Renviron'. | ||
v Found key `R_BUGZILLA`. | ||
v Using key `R_BUGZILLA`. | ||
x Not authenticated on this site. | ||
v Authenticated on this site! | ||
|
||
# create_bugzilla_key() works [unicode] | ||
|
||
Code | ||
create_bugzilla_key() | ||
Message <cliMessage> | ||
ℹ Reading cached keys on '/home/data/.cache/R/bugRzilla/.Renviron'. | ||
✔ Found key `R_BUGZILLA`. | ||
✔ Using key `R_BUGZILLA`. | ||
✖ Not authenticated on this site. | ||
✔ Authenticated on this site! | ||
|
||
# check_key() works [plain] | ||
|
||
Code | ||
check_key(key_name = missing_key(), verbose = FALSE) | ||
Output | ||
[1] TRUE | ||
|
||
# check_key() works [unicode] | ||
|
||
Code | ||
check_key(key_name = missing_key(), verbose = FALSE) | ||
Output | ||
[1] TRUE | ||
|
||
# use_key() works [plain] | ||
|
||
Code | ||
use_key(missing_key()) | ||
Message <cliMessage> | ||
v Using key `R_BUGZILLA`. | ||
|
||
# use_key() works [unicode] | ||
|
||
Code | ||
use_key(missing_key()) | ||
Message <cliMessage> | ||
✔ Using key `R_BUGZILLA`. | ||
|
||
# valid_key() works [plain] | ||
|
||
Code | ||
valid_key(key = "hgfcchg12") | ||
Output | ||
[1] TRUE | ||
|
||
# valid_key() works [ansi] | ||
|
||
Code | ||
valid_key(key = "hgfcchg12") | ||
Output | ||
[1] TRUE | ||
|
||
# valid_key() works [unicode] | ||
|
||
Code | ||
valid_key(key = "hgfcchg12") | ||
Output | ||
[1] TRUE | ||
|
||
# valid_key() works [fancy] | ||
|
||
Code | ||
valid_key(key = "hgfcchg12") | ||
Output | ||
[1] TRUE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# This is to check the create_bugzilla_key function | ||
cli::test_that_cli(configs = c("plain", "unicode"), "create_bugzilla_key() works", { | ||
skip_on_ci() | ||
expect_snapshot({ | ||
create_bugzilla_key() | ||
}) | ||
}) | ||
|
||
|
||
# This is to check the set_key function | ||
test_that("set_key works", { | ||
skip_on_ci() | ||
sk <- set_key() | ||
expect_equal(write_renviron(key = sk, value = sk, file = app_file()), NULL) | ||
}) | ||
|
||
|
||
# This is to check the check_key function | ||
cli::test_that_cli(configs = c("plain", "unicode"), "check_key() works", { | ||
skip_on_ci() | ||
expect_snapshot({ | ||
check_key(key_name = missing_key(), verbose = FALSE) | ||
}) | ||
}) | ||
|
||
# This is to check the use_key function | ||
cli::test_that_cli(configs = c("plain", "unicode"), "use_key() works", { | ||
expect_snapshot({ | ||
use_key(missing_key()) | ||
}) | ||
}) | ||
|
||
|
||
# This is to check the check_last_audit function | ||
test_that("check_last_audit works", { | ||
vcr::use_cassette("check_last_audit", { | ||
cla <- check_last_audit() | ||
}) | ||
expect_s3_class(cla, "POSIXlt") | ||
}) | ||
|
||
|
||
# This is to check the valid_key function | ||
cli::test_that_cli("valid_key() works", { | ||
expect_snapshot({ | ||
valid_key(key = "hgfcchg12") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
valid_parameters <- c("alias", "assigned_to", "component", "creation_time", | ||
"creator", "id", "last_change_time", "limit", | ||
"longdescs.count", "offset", "op_sys", "platform", | ||
"priority", "product", "resolution", "severity", | ||
"status", "summary", "tags", "target_milestone", | ||
"qa_contact", "url", "version", "whiteboard", | ||
"quicksearch") | ||
|
||
# test_that("bug_search works", { | ||
# vcr::use_cassette("bug_search", { | ||
# bs <- bug_search(id=1) | ||
# url <- "https://bugs.r-project.org/bugzilla/rest/bug?id=1" | ||
# }) | ||
# expect_equal(paste0(missing_host(), "rest/bug?", params(id=1)), url) | ||
# }) | ||
|
||
test_that("params works", { | ||
par <- params() | ||
expect_true(all(names(par) %in% valid_parameters)) | ||
expect_error(params(ids=1)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# yes <- c("Yes", "Definitely", "Positive", "For sure", "Yup", "Yeah", | ||
# "Absolutely") | ||
# no <- c("Not sure", "Not now", "Negative", "No", "Nope", "Absolutely not") | ||
# | ||
# cli::test_that_cli(configs = c("plain"), "read_documentation() works",{ | ||
# expect_snapshot({ | ||
# expect_equal(read_documentation(), "Cancel") | ||
# # expect_equal(read_documentation(), no) | ||
# # expect_equal(read_documentation(), yes) | ||
# }) | ||
# }) | ||
|
||
# test_that("ask_confirmation works", { | ||
# vcr::use_cassette("ask_confirmation", { | ||
# ac <- ask_confirmation(title = NULL, positive = yes, negative = no) | ||
# }) | ||
# expect_equal(sample(positive, 1), sample(negative, 2)) | ||
# }) |