test/test_database.rb in extralite-1.18 vs test/test_database.rb in extralite-1.19
- old
+ new
@@ -205,9 +205,45 @@
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_multi
+ @db.query('create table foo (a, b, c)')
+ assert_equal [], @db.query('select * from foo')
+
+ records = [
+ [1, '2', 3],
+ ['4', 5, 6]
+ ]
+
+ changes = @db.execute_multi('insert into foo values (?, ?, ?)', records)
+
+ assert_equal 2, changes
+ assert_equal [
+ { a: 1, b: '2', c: 3 },
+ { a: '4', b: 5, c: 6 }
+ ], @db.query('select * from foo')
+ end
+
+ def test_execute_multi_single_values
+ @db.query('create table foo (bar)')
+ assert_equal [], @db.query('select * from foo')
+
+ records = [
+ 'hi',
+ 'bye'
+ ]
+
+ changes = @db.execute_multi('insert into foo values (?)', records)
+
+ assert_equal 2, changes
+ assert_equal [
+ { bar: 'hi' },
+ { bar: 'bye' }
+ ], @db.query('select * from foo')
+ end
end
class ScenarioTest < MiniTest::Test
def setup
@db = Extralite::Database.new('/tmp/extralite.db')