Skip to content

Commit

Permalink
Fix Databricks unit tests when running in Workbench.
Browse files Browse the repository at this point in the history
Previously, these tests could fail because they picked up on ambient
credentials and environment variables set by Workbench. This commit
fixes those issues by ignoring these credentials in unit tests.

Signed-off-by: Aaron Jacobs <[email protected]>
  • Loading branch information
atheriel committed May 17, 2024
1 parent 9cdcfb0 commit 65fcf6d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/testthat/test-driver-databricks.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ test_that("databricks host validates inputs", {
})

test_that("user agent respects envvar", {
withr::local_envvar(SPARK_CONNECT_USER_AGENT = NULL)
local_mocked_bindings(packageVersion = function(...) "1.0.0")
expect_equal(databricks_user_agent(), "r-odbc/1.0.0")

Expand Down Expand Up @@ -73,7 +74,7 @@ test_that("must supply both uid and pwd", {

test_that("supports PAT in env var", {
withr::local_envvar(DATABRICKS_TOKEN = "abc")
expect_equal(databricks_auth_args()$pwd, "abc")
expect_equal(databricks_auth_args("host")$pwd, "abc")
})

test_that("supports OAuth M2M in env var", {
Expand All @@ -83,7 +84,7 @@ test_that("supports OAuth M2M in env var", {
DATABRICKS_CLIENT_SECRET = "def"
)

auth <- databricks_auth_args()
auth <- databricks_auth_args("host")
expect_equal(auth$auth_client_id, "abc")
expect_equal(auth$auth_client_secret, "def")
})
Expand Down

0 comments on commit 65fcf6d

Please sign in to comment.