Class: SQLite3::TestDatabaseFlags
- Defined in:
- lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb,
lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_flags.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #teardown ⇒ Object
- #test_open_database_create_flags ⇒ Object
- #test_open_database_exotic_flags ⇒ Object
- #test_open_database_flags_conflicts_with_readonly ⇒ Object
- #test_open_database_flags_conflicts_with_readwrite ⇒ Object
- #test_open_database_flags_constants ⇒ Object
- #test_open_database_misuse_flags ⇒ Object
- #test_open_database_readonly_flags ⇒ Object
- #test_open_database_readonly_flags_cant_open ⇒ Object
- #test_open_database_readwrite_flags ⇒ Object
- #test_open_database_readwrite_flags_cant_open ⇒ Object
Methods inherited from TestCase
Instance Method Details
#setup ⇒ Object
5 6 7 8 9 10 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb', line 5 def setup File.unlink 'test-flags.db' if File.exist?('test-flags.db') @db = SQLite3::Database.new('test-flags.db') @db.execute("CREATE TABLE foos (id integer)") @db.close end |
#teardown ⇒ Object
12 13 14 15 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb', line 12 def teardown @db.close unless @db.closed? File.unlink 'test-flags.db' if File.exist?('test-flags.db') end |
#test_open_database_create_flags ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb', line 77 def test_open_database_create_flags File.unlink 'test-flags.db' flags = SQLite3::Constants::Open::READWRITE | SQLite3::Constants::Open::CREATE @db = SQLite3::Database.new('test-flags.db', :flags => flags) do |db| db.execute("CREATE TABLE foos (id integer)") db.execute("INSERT INTO foos (id) VALUES (12)") end assert File.exist?('test-flags.db') end |
#test_open_database_exotic_flags ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb', line 87 def test_open_database_exotic_flags flags = SQLite3::Constants::Open::READWRITE | SQLite3::Constants::Open::CREATE exotic_flags = SQLite3::Constants::Open::NOMUTEX | SQLite3::Constants::Open::TEMP_DB @db = SQLite3::Database.new('test-flags.db', :flags => flags | exotic_flags) @db.execute("INSERT INTO foos (id) VALUES (12)") assert @db.changes == 1 end |
#test_open_database_flags_conflicts_with_readonly ⇒ Object
34 35 36 37 38 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb', line 34 def test_open_database_flags_conflicts_with_readonly assert_raise(RuntimeError) do @db = SQLite3::Database.new('test-flags.db', :flags => 2, :readonly => true) end end |
#test_open_database_flags_conflicts_with_readwrite ⇒ Object
40 41 42 43 44 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb', line 40 def test_open_database_flags_conflicts_with_readwrite assert_raise(RuntimeError) do @db = SQLite3::Database.new('test-flags.db', :flags => 2, :readwrite => true) end end |
#test_open_database_flags_constants ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb', line 17 def test_open_database_flags_constants defined_to_date = [:READONLY, :READWRITE, :CREATE, :DELETEONCLOSE, :EXCLUSIVE, :MAIN_DB, :TEMP_DB, :TRANSIENT_DB, :MAIN_JOURNAL, :TEMP_JOURNAL, :SUBJOURNAL, :MASTER_JOURNAL, :NOMUTEX, :FULLMUTEX] if SQLite3::SQLITE_VERSION_NUMBER > 3007002 defined_to_date += [:AUTOPROXY, :SHAREDCACHE, :PRIVATECACHE, :WAL] end if SQLite3::SQLITE_VERSION_NUMBER > 3007007 defined_to_date += [:URI] end if SQLite3::SQLITE_VERSION_NUMBER > 3007013 defined_to_date += [:MEMORY] end assert defined_to_date.sort == SQLite3::Constants::Open.constants.sort end |
#test_open_database_misuse_flags ⇒ Object
70 71 72 73 74 75 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb', line 70 def test_open_database_misuse_flags assert_raise(SQLite3::MisuseException) do flags = SQLite3::Constants::Open::READONLY | SQLite3::Constants::Open::READWRITE # <== incompatible flags @db = SQLite3::Database.new('test-flags.db', :flags => flags) end end |
#test_open_database_readonly_flags ⇒ Object
46 47 48 49 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb', line 46 def test_open_database_readonly_flags @db = SQLite3::Database.new('test-flags.db', :flags => SQLite3::Constants::Open::READONLY) assert @db.readonly? end |
#test_open_database_readonly_flags_cant_open ⇒ Object
56 57 58 59 60 61 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb', line 56 def test_open_database_readonly_flags_cant_open File.unlink 'test-flags.db' assert_raise(SQLite3::CantOpenException) do @db = SQLite3::Database.new('test-flags.db', :flags => SQLite3::Constants::Open::READONLY) end end |
#test_open_database_readwrite_flags ⇒ Object
51 52 53 54 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb', line 51 def test_open_database_readwrite_flags @db = SQLite3::Database.new('test-flags.db', :flags => SQLite3::Constants::Open::READWRITE) assert !@db.readonly? end |
#test_open_database_readwrite_flags_cant_open ⇒ Object
63 64 65 66 67 68 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb', line 63 def test_open_database_readwrite_flags_cant_open File.unlink 'test-flags.db' assert_raise(SQLite3::CantOpenException) do @db = SQLite3::Database.new('test-flags.db', :flags => SQLite3::Constants::Open::READWRITE) end end |