Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Prompt actions
54 changes: 27 additions & 27 deletions tests/testthat/test-objr.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
)

expect_s3_class(objr_auth(req), "httr2_request")
# expect_equal(objr_auth(req)$headers$Authorization, "test")

Check warning on line 55 in tests/testthat/test-objr.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-objr.R,line=55,col=5,[commented_code_linter] Remove commented code.

rm(token, pos = .GlobalEnv)

Expand All @@ -69,7 +69,7 @@
req_auth <- suppressMessages(objr_auth(req))

# expect_true(
# grepl("^Basic", req_auth$headers$Authorization)

Check warning on line 72 in tests/testthat/test-objr.R

View workflow job for this annotation

GitHub Actions / lint

file=tests/testthat/test-objr.R,line=72,col=7,[commented_code_linter] Remove commented code.
# )

expect_false(
Expand All @@ -78,28 +78,28 @@

})

# test_that("Correct authentication used", {
#
# expect_true(grepl("^Basic ", objr_auth(req)$headers$Authorization))
#
# .GlobalEnv$token <- "test" # nolint: object_name_linter
#
# exp_token1 <- objr_auth(req)
# expect_equal(exp_token1$headers$Authorization, "test")
#
# # Token used even when no username and password supplied
# with_envvar(
# new = c("OBJR_USR" = "",
# "OBJR_PWD" = ""),
# code = {
# exp_token2 <- objr_auth(req)
# expect_equal(exp_token2$headers$Authorization, "test")
# }
# )
#
# rm(token, pos = .GlobalEnv)
#
# })
test_that("Correct authentication used", {

expect_true(grepl("^Basic ", objr_auth(req)$headers$Authorization))

.GlobalEnv$token <- "test" # nolint: object_name_linter

exp_token1 <- objr_auth(req)
expect_equal(exp_token1$headers$Authorization, "test")

# Token used even when no username and password supplied
with_envvar(
new = c("OBJR_USR" = "",
"OBJR_PWD" = ""),
code = {
exp_token2 <- objr_auth(req)
expect_equal(exp_token2$headers$Authorization, "test")
}
)

rm(token, pos = .GlobalEnv)

})


# store_token ----
Expand Down Expand Up @@ -150,11 +150,11 @@
"character"
)

# expect_type(
# error(httr2::response(status_code = 403,
# body = list(description = "x"))),
# "character"
# )
expect_type(
error(httr2::response(status_code = 403,
body = list(description = "x"))),
"character"
)

expect_type(
error(httr2::response_json(
Expand Down
Loading