@@ -15,14 +15,6 @@ class SchemaDumperTest < ActiveRecord::TestCase
1515 @schema_migration . create_table
1616 end
1717
18- def standard_dump
19- @@standard_dump ||= perform_schema_dump
20- end
21-
22- def perform_schema_dump
23- dump_all_table_schema [ ]
24- end
25-
2618 # See https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/347
2719 def test_dump_index_rather_than_unique_constraints
2820 ActiveRecord ::Base . with_connection do |conn |
@@ -35,13 +27,9 @@ def test_dump_index_rather_than_unique_constraints
3527 end
3628 end
3729
38- stream = StringIO . new
39- ActiveRecord ::Base . connection_pool . with_connection do |conn |
40- dumper = conn . create_schema_dumper ( { } )
41- dumper . send ( :table , "payments" , stream )
42- end
43- stream . rewind
44- index_lines = stream . each_line . select { _1 [ /simple_unique|unique_with_where|as_unique_constraint/ ] }
30+ output = dump_table_schema ( "payments" )
31+
32+ index_lines = output . each_line . select { _1 [ /simple_unique|unique_with_where|as_unique_constraint/ ] }
4533 assert_equal 2 , index_lines . size
4634 index_lines . each do |line |
4735 assert_match ( /t.index/ , line )
@@ -69,7 +57,8 @@ def down
6957 end
7058 migration . migrate ( :up )
7159
72- output = perform_schema_dump
60+ output = dump_table_schema "timestamps"
61+
7362 assert output . include? ( 't.datetime "this_should_remain_datetime"' )
7463 assert output . include? ( 't.datetime "this_is_an_alias_of_datetime"' )
7564 assert output . include? ( 't.timestamp "without_time_zone"' )
@@ -97,7 +86,7 @@ def down
9786 end
9887 migration . migrate ( :up )
9988
100- output = perform_schema_dump
89+ output = dump_table_schema "timestamps"
10190 # Normally we'd write `t.datetime` here. But because you've changed the `datetime_type`
10291 # to something else, `t.datetime` now means `:timestamptz`. To ensure that old columns
10392 # are still created as a `:timestamp` we need to change what is written to the schema dump.
@@ -131,7 +120,7 @@ def down
131120 end
132121 migration . migrate ( :up )
133122
134- output = perform_schema_dump
123+ output = dump_table_schema "timestamps"
135124 # Normally we'd write `t.datetime` here. But because you've changed the `datetime_type`
136125 # to something else, `t.datetime` now means `:timestamptz`. To ensure that old columns
137126 # are still created as a `:timestamp` we need to change what is written to the schema dump.
@@ -166,7 +155,7 @@ def down
166155 end
167156 migration . migrate ( :up )
168157
169- output = perform_schema_dump
158+ output = dump_table_schema "timestamps"
170159 # Normally we'd write `t.datetime` here. But because you've changed the `datetime_type`
171160 # to something else, `t.datetime` now means `:timestamptz`. To ensure that old columns
172161 # are still created as a `:timestamp` we need to change what is written to the schema dump.
@@ -200,15 +189,15 @@ def down
200189 end
201190 migration . migrate ( :up )
202191
203- output = perform_schema_dump
192+ output = dump_table_schema "timestamps"
204193 assert output . include? ( 't.datetime "default_format"' )
205194 assert output . include? ( 't.datetime "without_time_zone"' )
206195 assert output . include? ( 't.timestamptz "with_time_zone"' )
207196
208197 datetime_type_was = ActiveRecord ::ConnectionAdapters ::CockroachDBAdapter . datetime_type
209198 ActiveRecord ::ConnectionAdapters ::CockroachDBAdapter . datetime_type = :timestamptz
210199
211- output = perform_schema_dump
200+ output = dump_table_schema "timestamps"
212201 assert output . include? ( 't.timestamp "default_format"' )
213202 assert output . include? ( 't.timestamp "without_time_zone"' )
214203 assert output . include? ( 't.datetime "with_time_zone"' )
0 commit comments