From a75a7f9363401ee987a79d70ab8c50da7b89deb5 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Tue, 29 Oct 2024 14:55:47 -0400 Subject: [PATCH] test: skil URI tests on windows there are a lot of caveats about them in https://www.sqlite.org/uri.html and I don't have the energy to deal with it today. --- test/helper.rb | 4 ++++ test/test_database_uri.rb | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/test/helper.rb b/test/helper.rb index 9f159247..32ac8dd8 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -21,5 +21,9 @@ def i_am_running_in_valgrind # https://stackoverflow.com/questions/365458/how-can-i-detect-if-a-program-is-running-from-within-valgrind/62364698#62364698 ENV["LD_PRELOAD"] =~ /valgrind|vgpreload/ end + + def windows? + ::RUBY_PLATFORM =~ /mingw|mswin/ + end end end diff --git a/test/test_database_uri.rb b/test/test_database_uri.rb index 6c3dfe31..909c93c5 100644 --- a/test/test_database_uri.rb +++ b/test/test_database_uri.rb @@ -5,27 +5,39 @@ module SQLite3 class TestDatabaseURI < SQLite3::TestCase def test_open_absolute_file_uri + skip("windows uri paths are hard") if windows? + Tempfile.open "test.db" do |file| - assert SQLite3::Database.new("file:#{file.path}") + db = SQLite3::Database.new("file:#{file.path}") + assert db + db.close end end def test_open_relative_file_uri + skip("windows uri paths are hard") if windows? + Dir.mktmpdir do |dir| Dir.chdir dir do - assert SQLite3::Database.new("file:test.db") + db = SQLite3::Database.new("file:test.db") + assert db assert_path_exists "test.db" + db.close end end end def test_open_file_uri_readonly + skip("windows uri paths are hard") if windows? + Tempfile.open "test.db" do |file| db = SQLite3::Database.new("file:#{file.path}?mode=ro") assert_raise(SQLite3::ReadOnlyException) do db.execute("CREATE TABLE foos (id integer)") end + + db.close end end end