Skip to content

Commit

Permalink
test: skil URI tests on windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
flavorjones committed Oct 29, 2024
1 parent ba3de83 commit a75a7f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 14 additions & 2 deletions test/test_database_uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a75a7f9

Please sign in to comment.