Skip to content
Merged
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
43 changes: 22 additions & 21 deletions rust/driver_manager/src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1208,31 +1208,32 @@ mod tests {
#[test]
#[cfg_attr(not(feature = "driver_manager_test_lib"), ignore)]
fn test_load_relative_path() {
std::fs::write(PathBuf::from("sqlite.toml"), simple_manifest())
std::fs::write(PathBuf::from("test_sqlite.toml"), simple_manifest())
.expect("Failed to write driver manager manifest to file");

let err = ManagedDriver::load_from_name("sqlite.toml", None, AdbcVersion::V100, 0, None)
.unwrap_err();
let err =
ManagedDriver::load_from_name("test_sqlite.toml", None, AdbcVersion::V100, 0, None)
.unwrap_err();
assert_eq!(err.status, Status::InvalidArguments);

ManagedDriver::load_from_name(
"sqlite.toml",
"test_sqlite.toml",
None,
AdbcVersion::V100,
LOAD_FLAG_ALLOW_RELATIVE_PATHS,
None,
)
.unwrap();

std::fs::remove_file("sqlite.toml")
std::fs::remove_file("test_sqlite.toml")
.expect("Failed to remove temporary driver manifest file");
}

#[test]
#[cfg_attr(not(feature = "driver_manager_test_lib"), ignore)]
fn test_manifest_missing_driver() {
let (tmp_dir, manifest_path) = write_manifest_to_tempfile(
PathBuf::from("sqlite.toml"),
PathBuf::from("test_sqlite.toml"),
manifest_without_driver().to_string(),
);

Expand All @@ -1256,7 +1257,7 @@ mod tests {
fn test_manifest_bad_version() {
let manifest = "manifest_version = 2\n".to_owned() + &simple_manifest().to_owned();
let (tmp_dir, manifest_path) =
write_manifest_to_tempfile(PathBuf::from("sqlite.toml"), manifest);
write_manifest_to_tempfile(PathBuf::from("test_sqlite.toml"), manifest);

let err = ManagedDriver::load_from_name(
manifest_path,
Expand Down Expand Up @@ -1288,7 +1289,7 @@ mod tests {
);

let (tmp_dir, manifest_path) =
write_manifest_to_tempfile(PathBuf::from("sqlite.toml"), manifest_wrong_arch);
write_manifest_to_tempfile(PathBuf::from("test_sqlite.toml"), manifest_wrong_arch);

let err = ManagedDriver::load_from_name(
manifest_path,
Expand All @@ -1309,7 +1310,7 @@ mod tests {
#[cfg_attr(not(feature = "driver_manager_test_lib"), ignore)]
fn test_load_absolute_path() {
let (tmp_dir, manifest_path) =
write_manifest_to_tempfile(PathBuf::from("sqlite.toml"), simple_manifest());
write_manifest_to_tempfile(PathBuf::from("test_sqlite.toml"), simple_manifest());

ManagedDriver::load_from_name(
manifest_path,
Expand All @@ -1329,7 +1330,7 @@ mod tests {
#[cfg_attr(not(feature = "driver_manager_test_lib"), ignore)]
fn test_load_absolute_path_no_ext() {
let (tmp_dir, mut manifest_path) =
write_manifest_to_tempfile(PathBuf::from("sqlite.toml"), simple_manifest());
write_manifest_to_tempfile(PathBuf::from("test_sqlite.toml"), simple_manifest());

manifest_path.set_extension("");
ManagedDriver::load_from_name(
Expand All @@ -1353,7 +1354,7 @@ mod tests {
// ensure that we fail without the env var set
with_var_unset("ADBC_DRIVER_PATH", || {
let err = ManagedDriver::load_from_name(
"sqlite",
"test_sqlite",
None,
AdbcVersion::V100,
adbc_core::LOAD_FLAG_SEARCH_ENV,
Expand All @@ -1364,14 +1365,14 @@ mod tests {
});

let (tmp_dir, manifest_path) =
write_manifest_to_tempfile(PathBuf::from("sqlite.toml"), simple_manifest());
write_manifest_to_tempfile(PathBuf::from("test_sqlite.toml"), simple_manifest());

with_var(
"ADBC_DRIVER_PATH",
Some(manifest_path.parent().unwrap().as_os_str()),
|| {
ManagedDriver::load_from_name(
"sqlite",
"test_sqlite",
None,
AdbcVersion::V100,
adbc_core::LOAD_FLAG_SEARCH_ENV,
Expand All @@ -1390,7 +1391,7 @@ mod tests {
#[cfg_attr(not(feature = "driver_manager_test_lib"), ignore)]
fn test_load_driver_env_multiple_paths() {
let (tmp_dir, manifest_path) =
write_manifest_to_tempfile(PathBuf::from("sqlite.toml"), simple_manifest());
write_manifest_to_tempfile(PathBuf::from("test_sqlite.toml"), simple_manifest());

let path_os_string = env::join_paths([
Path::new("/home"),
Expand All @@ -1401,7 +1402,7 @@ mod tests {

with_var("ADBC_DRIVER_PATH", Some(&path_os_string), || {
ManagedDriver::load_from_name(
"sqlite",
"test_sqlite",
None,
AdbcVersion::V100,
adbc_core::LOAD_FLAG_SEARCH_ENV,
Expand All @@ -1418,11 +1419,11 @@ mod tests {
#[test]
#[cfg_attr(not(feature = "driver_manager_test_lib"), ignore)]
fn test_load_additional_path() {
let p = PathBuf::from("majestik møøse/sqlite.toml");
let p = PathBuf::from("majestik møøse/test_sqlite.toml");
let (tmp_dir, manifest_path) = write_manifest_to_tempfile(p, simple_manifest());

ManagedDriver::load_from_name(
"sqlite",
"test_sqlite",
None,
AdbcVersion::V100,
adbc_core::LOAD_FLAG_SEARCH_ENV,
Expand Down Expand Up @@ -1459,15 +1460,15 @@ mod tests {
#[test]
#[cfg_attr(not(feature = "driver_manager_test_lib"), ignore)]
fn test_load_non_ascii_path() {
let p = PathBuf::from("majestik møøse/sqlite.toml");
let p = PathBuf::from("majestik møøse/test_sqlite.toml");
let (tmp_dir, manifest_path) = write_manifest_to_tempfile(p, simple_manifest());

with_var(
"ADBC_DRIVER_PATH",
Some(manifest_path.parent().unwrap().as_os_str()),
|| {
ManagedDriver::load_from_name(
"sqlite",
"test_sqlite",
None,
AdbcVersion::V100,
adbc_core::LOAD_FLAG_SEARCH_ENV,
Expand All @@ -1487,15 +1488,15 @@ mod tests {
#[cfg_attr(target_os = "windows", ignore)] // TODO: remove this line after fixing
fn test_disallow_env_config() {
let (tmp_dir, manifest_path) =
write_manifest_to_tempfile(PathBuf::from("sqlite.toml"), simple_manifest());
write_manifest_to_tempfile(PathBuf::from("test_sqlite.toml"), simple_manifest());

with_var(
"ADBC_DRIVER_PATH",
Some(manifest_path.parent().unwrap().as_os_str()),
|| {
let load_flags = adbc_core::LOAD_FLAG_DEFAULT & !adbc_core::LOAD_FLAG_SEARCH_ENV;
let err = ManagedDriver::load_from_name(
"sqlite",
"test_sqlite",
None,
AdbcVersion::V100,
load_flags,
Expand Down
4 changes: 2 additions & 2 deletions rust/driver_manager/tests/connection_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,15 +674,15 @@ shared = "{driver_path}"
"#
);

let manifest_path = manifest_dir.path().join("sqlite.toml");
let manifest_path = manifest_dir.path().join("test_sqlite.toml");
std::fs::write(&manifest_path, &manifest_contents).unwrap();

let manifest_path = profile_dir.path().join("sqlitemani.toml");
std::fs::write(&manifest_path, &manifest_contents).unwrap();

let profile_contents = r#"
profile_version = 1
driver = "sqlite"
driver = "test_sqlite"
[Options]
uri = ":memory:"
"#;
Expand Down
Loading