Sha256: 3461ab2d6e06913d2f2cfe9f5fe5d8d6797fa6f61fad99a3374295367f9b84cf

Contents?: true

Size: 1.2 KB

Versions: 291

Compression:

Stored size: 1.2 KB

Contents

require 'helper'

module SQLite3
  class TestDatabaseReadwrite < SQLite3::TestCase
    def setup
      File.unlink 'test-readwrite.db' if File.exist?('test-readwrite.db')
      @db = SQLite3::Database.new('test-readwrite.db')
      @db.execute("CREATE TABLE foos (id integer)")
      @db.close
    end

    def teardown
      @db.close unless @db.closed?
      File.unlink 'test-readwrite.db' if File.exist?('test-readwrite.db')
    end

    def test_open_readwrite_database
      @db = SQLite3::Database.new('test-readwrite.db', :readwrite => true)
      assert !@db.readonly?
    end

    def test_open_readwrite_readonly_database
      assert_raise(RuntimeError) do
        @db = SQLite3::Database.new('test-readwrite.db', :readwrite => true, :readonly => true)
      end
    end

    def test_open_readwrite_not_exists_database
      File.unlink 'test-readwrite.db'
      assert_raise(SQLite3::CantOpenException) do
        @db = SQLite3::Database.new('test-readwrite.db', :readonly => true)
      end
    end

    def test_insert_readwrite_database
      @db = SQLite3::Database.new('test-readwrite.db', :readwrite => true)
      @db.execute("INSERT INTO foos (id) VALUES (12)")
      assert @db.changes == 1
    end
  end
end

Version data entries

291 entries across 261 versions & 7 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/sqlite3-1.7.3-arm64-darwin/test/test_database_readwrite.rb
sqlite3-1.7.3 test/test_database_readwrite.rb
sqlite3-1.7.3-x86_64-linux test/test_database_readwrite.rb
sqlite3-1.7.3-x86_64-darwin test/test_database_readwrite.rb
sqlite3-1.7.3-x86-linux test/test_database_readwrite.rb
sqlite3-1.7.3-x64-mingw32 test/test_database_readwrite.rb
sqlite3-1.7.3-x64-mingw-ucrt test/test_database_readwrite.rb
sqlite3-1.7.3-arm64-darwin test/test_database_readwrite.rb
sqlite3-1.7.3-arm-linux test/test_database_readwrite.rb
sqlite3-1.7.3-aarch64-linux test/test_database_readwrite.rb
sqlite3-1.7.2 test/test_database_readwrite.rb
sqlite3-1.7.2-x86_64-linux test/test_database_readwrite.rb
sqlite3-1.7.2-x86_64-darwin test/test_database_readwrite.rb
sqlite3-1.7.2-x86-linux test/test_database_readwrite.rb
sqlite3-1.7.2-x64-mingw32 test/test_database_readwrite.rb
sqlite3-1.7.2-x64-mingw-ucrt test/test_database_readwrite.rb
sqlite3-1.7.2-arm64-darwin test/test_database_readwrite.rb
sqlite3-1.7.2-arm-linux test/test_database_readwrite.rb
sqlite3-1.7.2-aarch64-linux test/test_database_readwrite.rb
sqlite3-1.7.1 test/test_database_readwrite.rb