aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/fixtures_test.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb
index 13034eef22..de5c96daaa 100644
--- a/activerecord/test/cases/fixtures_test.rb
+++ b/activerecord/test/cases/fixtures_test.rb
@@ -119,17 +119,19 @@ class FixturesTest < ActiveRecord::TestCase
if current_adapter?(:Mysql2Adapter)
def test_insert_fixtures_set_raises_an_error_when_max_allowed_packet_is_smaller_than_fixtures_set_size
conn = ActiveRecord::Base.connection
+ mysql_margin = 2
packet_size = 1024
+ bytes_needed_to_have_a_1024_bytes_fixture = 855
fixtures = {
"traffic_lights" => [
- { "location" => "US", "state" => ["NY"], "long_state" => ["a" * packet_size] },
+ { "location" => "US", "state" => ["NY"], "long_state" => ["a" * bytes_needed_to_have_a_1024_bytes_fixture] },
]
}
- conn.stubs(:max_allowed_packet).returns(packet_size)
+ conn.stubs(:max_allowed_packet).returns(packet_size - mysql_margin)
error = assert_raises(ActiveRecord::ActiveRecordError) { conn.insert_fixtures_set(fixtures) }
- assert_match(/Fixtures set is too large/, error.message)
+ assert_match(/Fixtures set is too large #{packet_size}\./, error.message)
end
def test_insert_fixture_set_when_max_allowed_packet_is_bigger_than_fixtures_set_size