diff --git a/test b/test new file mode 100644 index 0000000..1a7d5f6 --- /dev/null +++ b/test @@ -0,0 +1 @@ +# Prompt actions diff --git a/tests/testthat/test-objr.R b/tests/testthat/test-objr.R index a15501e..f3060a4 100644 --- a/tests/testthat/test-objr.R +++ b/tests/testthat/test-objr.R @@ -78,28 +78,28 @@ test_that("Uses usr/pwd if token exists but is expired", { }) -# 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 ---- @@ -150,11 +150,11 @@ test_that("Expect character value returned", { "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(