-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: allow URI filenames See https://www.sqlite.org/uri.html * 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: skip URI tests for sqlcipher since the compile-time option may not be on
- Loading branch information
1 parent
9899f06
commit c15fc69
Showing
4 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require "helper" | ||
require "tempfile" | ||
require "pathname" | ||
|
||
module SQLite3 | ||
class TestDatabaseURI < SQLite3::TestCase | ||
def test_open_absolute_file_uri | ||
skip("windows uri paths are hard") if windows? | ||
skip("sqlcipher may not allow URIs") if SQLite3.sqlcipher? | ||
|
||
Tempfile.open "test.db" do |file| | ||
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? | ||
skip("sqlcipher may not allow URIs") if SQLite3.sqlcipher? | ||
|
||
Dir.mktmpdir do |dir| | ||
Dir.chdir dir do | ||
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? | ||
skip("sqlcipher may not allow URIs") if SQLite3.sqlcipher? | ||
|
||
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 | ||
end |