@@ -710,15 +710,15 @@ class DriverManifest : public ::testing::Test {
710710 {" publisher" , " arrow-adbc" },
711711 {" version" , " X.Y.Z" },
712712 {" ADBC" ,
713- toml::table{
714- {" version" , " 1.1.0" },
713+ toml::table {
714+ {" version" , " 1.1.0" },
715715 }},
716716 {" Driver" ,
717- toml::table{
718- {" shared" ,
719- toml::table{
720- {InternalAdbcCurrentArch (), driver_path.string ()},
721- }},
717+ toml::table {
718+ {" shared" ,
719+ toml::table {
720+ {InternalAdbcCurrentArch (), driver_path.string ()},
721+ }},
722722 }},
723723 };
724724
@@ -1364,6 +1364,82 @@ TEST_F(DriverManifest, CondaPrefix) {
13641364 }
13651365}
13661366
1367+ // A driver that does not exist should be reported as NOT_FOUND no matter how
1368+ // it was specified or which search locations are enabled.
1369+ namespace {
1370+ constexpr const char * kMissingDriverName =
1371+ " adbc_test_driver_manager_missing_driver_7c8f5482" ;
1372+
1373+ void ExpectMissingDriverNotFound (const std::string& driver_name,
1374+ AdbcLoadFlags load_options,
1375+ const char * additional_search_path_list = nullptr ) {
1376+ SCOPED_TRACE (" driver=" + driver_name + " load_options=" + std::to_string (load_options));
1377+ struct AdbcDriver driver = {};
1378+ struct AdbcError error = {};
1379+ EXPECT_THAT (
1380+ AdbcFindLoadDriver (driver_name.c_str (), nullptr , ADBC_VERSION_1_1_0 , load_options,
1381+ additional_search_path_list, &driver, &error),
1382+ IsStatus (ADBC_STATUS_NOT_FOUND , &error));
1383+ if (error.release ) {
1384+ error.release (&error);
1385+ }
1386+ if (driver.release ) {
1387+ driver.release (&driver, nullptr );
1388+ }
1389+ }
1390+
1391+ std::string MissingDriverDir () {
1392+ return (std::filesystem::temp_directory_path () / " adbc_missing_driver_dir_7c8f5482" )
1393+ .string ();
1394+ }
1395+
1396+ std::string PlatformLibraryName (const std::string& name) {
1397+ #if defined(_WIN32)
1398+ return name + " .dll" ;
1399+ #elif defined(__APPLE__)
1400+ return " lib" + name + " .dylib" ;
1401+ #else
1402+ return " lib" + name + " .so" ;
1403+ #endif
1404+ }
1405+ } // namespace
1406+
1407+ TEST (DriverManagerNotFound, BareNameAllLoadFlags) {
1408+ constexpr AdbcLoadFlags kAllFlags =
1409+ ADBC_LOAD_FLAG_SEARCH_ENV | ADBC_LOAD_FLAG_SEARCH_USER |
1410+ ADBC_LOAD_FLAG_SEARCH_SYSTEM | ADBC_LOAD_FLAG_ALLOW_RELATIVE_PATHS ;
1411+ for (AdbcLoadFlags flags = 0 ; flags <= kAllFlags ; ++flags) {
1412+ ExpectMissingDriverNotFound (kMissingDriverName , flags);
1413+ }
1414+ }
1415+
1416+ TEST (DriverManagerNotFound, BareNameAdditionalSearchPath) {
1417+ std::string search_path = MissingDriverDir ();
1418+ ExpectMissingDriverNotFound (kMissingDriverName , ADBC_LOAD_FLAG_DEFAULT ,
1419+ search_path.c_str ());
1420+ ExpectMissingDriverNotFound (kMissingDriverName , 0 , search_path.c_str ());
1421+ }
1422+
1423+ TEST (DriverManagerNotFound, AbsolutePathWithoutExtension) {
1424+ std::string path =
1425+ (std::filesystem::path (MissingDriverDir ()) / kMissingDriverName ).string ();
1426+ ExpectMissingDriverNotFound (path, ADBC_LOAD_FLAG_DEFAULT );
1427+ ExpectMissingDriverNotFound (path, 0 );
1428+ }
1429+
1430+ TEST (DriverManagerNotFound, AbsolutePathWithLibraryExtension) {
1431+ std::string path = (std::filesystem::path (MissingDriverDir ()) /
1432+ PlatformLibraryName (kMissingDriverName ))
1433+ .string ();
1434+ ExpectMissingDriverNotFound (path, ADBC_LOAD_FLAG_DEFAULT );
1435+ ExpectMissingDriverNotFound (path, 0 );
1436+ }
1437+
1438+ TEST (DriverManagerNotFound, RelativePathWithLibraryExtension) {
1439+ ExpectMissingDriverNotFound (PlatformLibraryName (kMissingDriverName ),
1440+ ADBC_LOAD_FLAG_DEFAULT );
1441+ }
1442+
13671443TEST_F (DriverManifest, ImplicitUri) {
13681444 auto filepath = temp_dir / " postgresql.toml" ;
13691445 std::ofstream test_manifest_file (filepath);
0 commit comments