Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helpers to set up test connections #634

Closed
hadley opened this issue Nov 29, 2023 · 2 comments · Fixed by #725
Closed

Helpers to set up test connections #634

hadley opened this issue Nov 29, 2023 · 2 comments · Fixed by #725

Comments

@hadley
Copy link
Member

hadley commented Nov 29, 2023

For local testing, we can lean on SQLite a lot more, and for macs at least, automatically look in some common brew paths to reduce the amount of setup needed.

@hadley
Copy link
Member Author

hadley commented Dec 7, 2023

Start for SQLite:

sqlite_driver <- function() {
  # Assume that if SQLite driver is setup up it's correct
  drivers <- unique(odbcListDrivers()$name)
  if ("SQLite" %in% drivers) {
    return("SQLite")
  }
  
  if (Sys.info()["sysname"] == "Darwin") {
    if (Sys.which("brew") == "") {
      abort("Homebrew is not installed")
    }
    
    paths <- system("brew list sqliteodbc", intern = TRUE)
    if (attr(paths, "status") != 0) {
      abort("Failed to list sqliteodbc brew file")
    }
    paths[basename(paths) == "libsqlite3odbc.dylib"]
  } else {
    abort("Autodiscovery currently only supported on macOS")
  }
}

Maybe this becomes sqlite_default_driver() and is used in #659?

@hadley
Copy link
Member Author

hadley commented Dec 13, 2023

And need to pull out non-DBItest tests into their own test_that() blocks with helper for getting a connection. Should come before DBItests, and maybe gate DBItests behind an env var it's easier to iterate locally, without running every single DBItest (which is only needed occasionally and on CI)

hadley added a commit that referenced this issue Jan 19, 2024
* Add `test_con()` helper and move individual database tests into own blocks
* Add `local_table()` helper

Fixes #634
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant