Skip to content

Commit 011ddff

Browse files
dtenenbasckott
authored andcommitted
add unit test for info endpoint
1 parent 84a2172 commit 011ddff

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tests/testthat/helper-stubs.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,13 @@ response_authenticate_success <- list(
5757
job_id = NULL,
5858
token_creation_date = NULL
5959
)
60+
61+
response_info_success <- list (
62+
logged_in_user = "someone",
63+
api_endpoint = "https://proof-api.fredhutch.org",
64+
branch = "main",
65+
commit_sha = "c4b85200632c2f9bd5e8173179208c3b32c7db7a",
66+
short_commit_sha = "c4b85200",
67+
commit_message = "two-eye lamb, as a so",
68+
tag = "v.0.1.0"
69+
)

tests/testthat/test-proof_info.R

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
test_that("proof_info - success", {
2+
stub_request("get", make_url("info")) %>%
3+
to_return(
4+
body = jsonlite::toJSON(response_info_success, auto_unbox = TRUE),
5+
status = 200L,
6+
headers = list("Content-type" = "application/json")
7+
)
8+
9+
enable(quiet = TRUE)
10+
11+
withr::with_envvar(c("PROOF_TOKEN" = "notarealtoken"), {
12+
info_res <- proof_info()
13+
})
14+
15+
expect_type(info_res, "list")
16+
expect_type(info_res$logged_in_user, "character")
17+
expect_type(info_res$api_endpoint, "character")
18+
19+
20+
stub_registry_clear()
21+
disable(quiet = TRUE)
22+
})

0 commit comments

Comments
 (0)