Sha256: 8e8c58c9af56fc1aeec20fa253b159eec88590aef40da8ec16cf35a49538187f
Contents?: true
Size: 1.3 KB
Versions: 3
Compression:
Stored size: 1.3 KB
Contents
require File.join(File.dirname(__FILE__), '_lib.rb') class MoSQL::Test::Functional::SQLTest < MoSQL::Test::Functional before do sequel.drop_table?(:test_upsert) sequel.create_table?(:test_upsert) do column :_id, 'INTEGER' column :color, 'TEXT' column :quantity, 'INTEGER' primary_key [:_id] end @adapter = MoSQL::SQLAdapter.new(nil, sql_test_uri) @table = sequel[:test_upsert] end describe 'upsert' do it 'inserts new items' do @adapter.upsert!(@table, '_id', {'_id' => 0, 'color' => 'red', 'quantity' => 10}) @adapter.upsert!(@table, '_id', {'_id' => 1, 'color' => 'blue', 'quantity' => 5}) assert_equal(2, @table.count) assert_equal('red', @table[:_id => 0][:color]) assert_equal(10, @table[:_id => 0][:quantity]) assert_equal('blue', @table[:_id => 1][:color]) assert_equal(5, @table[:_id => 1][:quantity]) end it 'updates items' do @adapter.upsert!(@table, '_id', {'_id' => 0, 'color' => 'red', 'quantity' => 10}) assert_equal(1, @table.count) assert_equal('red', @table[:_id => 0][:color]) @adapter.upsert!(@table, '_id', {'_id' => 0, 'color' => 'blue', 'quantity' => 5}) assert_equal(1, @table.count) assert_equal('blue', @table[:_id => 0][:color]) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mosql-0.3.1 | test/functional/sql.rb |
mosql-0.3.0 | test/functional/sql.rb |
mosql-0.2.0 | test/functional/sql.rb |