test/test_database.rb in extralite-2.0 vs test/test_database.rb in extralite-2.1
- old
+ new
@@ -204,10 +204,21 @@
assert_equal [], @db.pragma(schema_version: 33, recursive_triggers: 1)
assert_equal [{schema_version: 33}], @db.pragma(:schema_version)
assert_equal [{recursive_triggers: 1}], @db.pragma(:recursive_triggers)
end
+ def test_execute
+ changes = @db.execute('update t set x = 42')
+ assert_equal 2, changes
+ end
+
+ def test_execute_with_params
+ changes = @db.execute('update t set x = ? where z = ?', 42, 6)
+ assert_equal 1, changes
+ assert_equal [[1, 2, 3], [42, 5, 6]], @db.query_ary('select * from t order by x')
+ end
+
def test_execute_multi
@db.query('create table foo (a, b, c)')
assert_equal [], @db.query('select * from foo')
records = [
@@ -358,9 +369,24 @@
def test_close_with_open_prepared_statement
query = @db.prepare('select * from t')
query.next
@db.close
+ end
+
+ def test_read_only_database
+ db = Extralite::Database.new(':memory:')
+ db.query('create table foo (bar)')
+ assert_equal false, db.read_only?
+
+ db = Extralite::Database.new(':memory:', read_only: true)
+ assert_raises(Extralite::Error) { db.query('create table foo (bar)') }
+ assert_equal true, db.read_only?
+ end
+
+ def test_database_inspect
+ db = Extralite::Database.new(':memory:')
+ assert_match /^\#\<Extralite::Database:0x[0-9a-f]+ :memory:\>$/, db.inspect
end
end
class ScenarioTest < MiniTest::Test
def setup