Implemented tests for #get_value_insert_sets.
This commit is contained in:
parent
db173ef907
commit
5c5bd5f716
4 changed files with 201 additions and 28 deletions
53
test/active_record/connection_adapter_test.rb
Normal file
53
test/active_record/connection_adapter_test.rb
Normal file
|
@ -0,0 +1,53 @@
|
|||
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
||||
|
||||
describe "ActiveRecord::ConnectionADapter::AbstractAdapter" do
|
||||
context "#get_insert_value_sets - computing insert value sets" do
|
||||
let(:adapter){ ActiveRecord::ConnectionAdapters::AbstractAdapter }
|
||||
let(:base_sql){ "INSERT INTO atable (a,b,c)" }
|
||||
let(:values){ [ "(1,2,3)", "(2,3,4)", "(3,4,5)" ] }
|
||||
|
||||
context "when the max allowed bytes is 33 and the base SQL is 26 bytes" do
|
||||
it "should return 3 value sets when given 3 value sets of 7 bytes a piece" do
|
||||
value_sets = adapter.get_insert_value_sets values, base_sql.size, max_allowed_bytes = 33
|
||||
assert_equal 3, value_sets.size
|
||||
end
|
||||
end
|
||||
|
||||
context "when the max allowed bytes is 40 and the base SQL is 26 bytes" do
|
||||
it "should return 3 value sets when given 3 value sets of 7 bytes a piece" do
|
||||
value_sets = adapter.get_insert_value_sets values, base_sql.size, max_allowed_bytes = 40
|
||||
puts value_sets.inspect
|
||||
assert_equal 3, value_sets.size
|
||||
end
|
||||
end
|
||||
|
||||
context "when the max allowed bytes is 41 and the base SQL is 26 bytes" do
|
||||
it "should return 2 value sets when given 2 value sets of 7 bytes a piece" do
|
||||
value_sets = adapter.get_insert_value_sets values, base_sql.size, max_allowed_bytes = 41
|
||||
assert_equal 2, value_sets.size
|
||||
end
|
||||
end
|
||||
|
||||
context "when the max allowed bytes is 48 and the base SQL is 26 bytes" do
|
||||
it "should return 2 value sets when given 2 value sets of 7 bytes a piece" do
|
||||
value_sets = adapter.get_insert_value_sets values, base_sql.size, max_allowed_bytes = 48
|
||||
assert_equal 2, value_sets.size
|
||||
end
|
||||
end
|
||||
|
||||
context "when the max allowed bytes is 49 and the base SQL is 26 bytes" do
|
||||
it "should return 1 value sets when given 1 value sets of 7 bytes a piece" do
|
||||
value_sets = adapter.get_insert_value_sets values, base_sql.size, max_allowed_bytes = 49
|
||||
assert_equal 1, value_sets.size
|
||||
end
|
||||
end
|
||||
|
||||
context "when the max allowed bytes is 999999 and the base SQL is 26 bytes" do
|
||||
it "should return 1 value sets when given 1 value sets of 7 bytes a piece" do
|
||||
value_sets = adapter.get_insert_value_sets values, base_sql.size, max_allowed_bytes = 999999
|
||||
assert_equal 1, value_sets.size
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -215,32 +215,5 @@ describe "#import" do
|
|||
assert_equal "superx", Group.first.order
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# describe "computing insert value sets" do
|
||||
# context "when the max allowed bytes is 33 and the base SQL is 26 bytes" do
|
||||
# it "should return 3 value sets when given 3 value sets of 7 bytes a piece"
|
||||
# end
|
||||
#
|
||||
# context "when the max allowed bytes is 40 and the base SQL is 26 bytes" do
|
||||
# it "should return 3 value sets when given 3 value sets of 7 bytes a piece"
|
||||
# end
|
||||
#
|
||||
# context "when the max allowed bytes is 41 and the base SQL is 26 bytes" do
|
||||
# it "should return 3 value sets when given 2 value sets of 7 bytes a piece"
|
||||
# end
|
||||
#
|
||||
# context "when the max allowed bytes is 48 and the base SQL is 26 bytes" do
|
||||
# it "should return 3 value sets when given 2 value sets of 7 bytes a piece"
|
||||
# end
|
||||
#
|
||||
# context "when the max allowed bytes is 49 and the base SQL is 26 bytes" do
|
||||
# it "should return 3 value sets when given 1 value sets of 7 bytes a piece"
|
||||
# end
|
||||
#
|
||||
# context "when the max allowed bytes is 999999 and the base SQL is 26 bytes" do
|
||||
# it "should return 3 value sets when given 1 value sets of 7 bytes a piece"
|
||||
# end
|
||||
# end
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue