Class: SQLite3::TestDatabaseReadonly
- Defined in:
- lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readonly.rb,
lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_readonly.rb
Instance Method Summary collapse
- #setup ⇒ Object
- #teardown ⇒ Object
- #test_insert_readonly_database ⇒ Object
- #test_open_readonly_database ⇒ Object
- #test_open_readonly_not_exists_database ⇒ 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_readonly.rb', line 5 def setup File.unlink 'test-readonly.db' if File.exist?('test-readonly.db') @db = SQLite3::Database.new('test-readonly.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_readonly.rb', line 12 def teardown @db.close unless @db.closed? File.unlink 'test-readonly.db' if File.exist?('test-readonly.db') end |
#test_insert_readonly_database ⇒ Object
29 30 31 32 33 34 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readonly.rb', line 29 def test_insert_readonly_database @db = SQLite3::Database.new('test-readonly.db', :readonly => true) assert_raise(SQLite3::ReadOnlyException) do @db.execute("INSERT INTO foos (id) VALUES (12)") end end |
#test_open_readonly_database ⇒ Object
17 18 19 20 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readonly.rb', line 17 def test_open_readonly_database @db = SQLite3::Database.new('test-readonly.db', :readonly => true) assert @db.readonly? end |
#test_open_readonly_not_exists_database ⇒ Object
22 23 24 25 26 27 |
# File 'lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readonly.rb', line 22 def test_open_readonly_not_exists_database File.unlink 'test-readonly.db' assert_raise(SQLite3::CantOpenException) do @db = SQLite3::Database.new('test-readonly.db', :readonly => true) end end |