Class: SQLite3::TestDatabaseReadonly

Inherits:
TestCase
  • Object
show all
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

Methods inherited from TestCase

#assert_nothing_raised

Instance Method Details

#setupObject



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

#teardownObject



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_databaseObject



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_databaseObject



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_databaseObject



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