@@ -214,6 +214,59 @@ test_that("locate_install_unixodbc() returns reasonable values", {
214214 expect_true(grepl(" (\\ .dylib|\\ .a)$" , res [1 ]))
215215})
216216
217+ # https://github.com/r-dbi/odbc/issues/919
218+ test_that(" locate_install_unixodbc() prefers shlib" , {
219+ # odbc_config / pkg-config cflags point to nonexistent files on CRAN (#903)
220+ skip_on_cran()
221+ {
222+ local_mocked_bindings(
223+ is_macos = function () {TRUE }
224+ )
225+ local_mocked_bindings(
226+ list.files = function (path = " ." , pattern = NULL , all.files = FALSE , full.names = FALSE , ... ) {
227+ # Mimic being able to find any pattern passed as argument
228+ return (pattern )
229+ },
230+ .package = " base"
231+ )
232+ res <- locate_install_unixodbc()
233+ expect_equal(length(res ), 1 )
234+ expect_true(grepl(" (\\ .dylib)$" , res [1 ]))
235+ }
236+ {
237+ local_mocked_bindings(
238+ is_macos = function () {TRUE }
239+ )
240+ local_mocked_bindings(
241+ list.files = function (path = " ." , pattern = NULL , all.files = FALSE , full.names = FALSE , ... ) {
242+ # Mimic being able to find .a only
243+ if (pattern == " libodbcinst.a" ) return (pattern )
244+ return (character ())
245+ },
246+ .package = " base"
247+ )
248+ res <- locate_install_unixodbc()
249+ expect_equal(length(res ), 1 )
250+ expect_true(grepl(" (\\ .a)$" , res [1 ]))
251+ }
252+ {
253+ local_mocked_bindings(
254+ is_macos = function () {TRUE }
255+ )
256+ local_mocked_bindings(
257+ list.files = function (path = " ." , pattern = NULL , all.files = FALSE , full.names = FALSE , ... ) {
258+ # Mimic being able to find shlib only
259+ if (pattern == " libodbcinst.dylib" ) return (pattern )
260+ return (character ())
261+ },
262+ .package = " base"
263+ )
264+ res <- locate_install_unixodbc()
265+ expect_equal(length(res ), 1 )
266+ expect_true(grepl(" (\\ .dylib)$" , res [1 ]))
267+ }
268+ })
269+
217270test_that(" databricks() errors informatively when spark ini isn't writeable" , {
218271 local_mocked_bindings(is_writeable = function (path ) {FALSE })
219272 expect_snapshot(
0 commit comments