pseudo_cleaner 0.0.34 → 0.0.35

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,13 +47,40 @@ RSpec.configure do |config|
47
47
  end
48
48
  new_strategy ||= :transaction
49
49
 
50
- PseudoCleaner::MasterCleaner.start_example(test_example, new_strategy)
50
+ report_name = test_example.full_description
51
+ PseudoCleaner::MasterCleaner.start_example(test_example, new_strategy, "PseudoCleaner::start_test - #{report_name}")
51
52
  end
52
53
 
53
54
  config.after(:each) do |example|
54
55
  test_example = example
55
56
  test_example = example.example if example.respond_to?(:example)
56
57
 
57
- PseudoCleaner::MasterCleaner.end_example(test_example)
58
+ report_name = test_example.full_description
59
+
60
+ if test_example.metadata[:full_data_dump]
61
+ if (test_example.exception)
62
+ if PseudoCleaner::Configuration.instance.enable_full_data_dump_tag ||
63
+ PseudoCleaner::Configuration.instance.peek_data_on_error
64
+ PseudoCleaner::MasterCleaner.peek_data_inline("PseudoCleaner::peek_data - #{report_name}")
65
+ end
66
+ else
67
+ if PseudoCleaner::Configuration.instance.enable_full_data_dump_tag ||
68
+ PseudoCleaner::Configuration.instance.peek_data_not_on_error
69
+ PseudoCleaner::MasterCleaner.peek_data_new_test("PseudoCleaner::peek_data - #{report_name}")
70
+ end
71
+ end
72
+ else
73
+ if (test_example.exception)
74
+ if PseudoCleaner::Configuration.instance.peek_data_on_error
75
+ PseudoCleaner::MasterCleaner.peek_data_inline("PseudoCleaner::peek_data - #{report_name}")
76
+ end
77
+ else
78
+ if PseudoCleaner::Configuration.instance.peek_data_not_on_error
79
+ PseudoCleaner::MasterCleaner.peek_data_new_test("PseudoCleaner::peek_data - #{report_name}")
80
+ end
81
+ end
82
+ end
83
+
84
+ PseudoCleaner::MasterCleaner.end_example(test_example, "PseudoCleaner::end_test - #{report_name}")
58
85
  end
59
86
  end
@@ -1,8 +1,20 @@
1
+ require "singleton"
2
+
1
3
  first_test_run = false
2
4
 
3
5
  # I haven't tested this fully yet, but I think that this should work.
4
6
 
7
+ module PseudoCleaner
8
+ class SpinachErrorHandler
9
+ attr_accessor :exception
10
+
11
+ include Singleton
12
+ end
13
+ end
14
+
5
15
  Spinach.hooks.around_scenario do |scenario_data, step_definitions, &block|
16
+ PseudoCleaner::SpinachErrorHandler.exception = nil
17
+
6
18
  unless first_test_run
7
19
  first_test_run = true
8
20
  # before tests run...
@@ -16,24 +28,58 @@ Spinach.hooks.around_scenario do |scenario_data, step_definitions, &block|
16
28
  DatabaseCleaner.strategy = :transaction
17
29
  end
18
30
 
19
- strategy = if scenario_data.tags.include?("@none")
20
- :none
21
- elsif scenario_data.tags.include?("@truncation")
22
- :truncation
23
- elsif scenario_data.tags.include?("@deletion")
24
- :deletion
25
- else
26
- :pseudo_delete
27
- end
28
- PseudoCleaner::MasterCleaner.start_example(scenario_data, strategy)
31
+ report_name = "#{scenario_data.feature.name} : #{scenario_data.name}"
32
+ strategy = if scenario_data.tags.include?("@none")
33
+ :none
34
+ elsif scenario_data.tags.include?("@truncation")
35
+ :truncation
36
+ elsif scenario_data.tags.include?("@deletion")
37
+ :deletion
38
+ else
39
+ :pseudo_delete
40
+ end
41
+ PseudoCleaner::MasterCleaner.start_example(scenario_data, strategy, "PseudoCleaner::start_test - #{report_name}")
29
42
 
30
43
  begin
31
44
  block.call
32
45
  ensure
33
- PseudoCleaner::MasterCleaner.end_example(scenario_data)
46
+ if scenario_data.tags.include?("@full_data_dump")
47
+ if PseudoCleaner::SpinachErrorHandler.exception
48
+ if PseudoCleaner::Configuration.instance.enable_full_data_dump_tag ||
49
+ PseudoCleaner::Configuration.instance.peek_data_on_error
50
+ PseudoCleaner::MasterCleaner.peek_data_inline("PseudoCleaner::peek_data - #{report_name}")
51
+ end
52
+ else
53
+ if PseudoCleaner::Configuration.instance.enable_full_data_dump_tag ||
54
+ PseudoCleaner::Configuration.instance.peek_data_not_on_error
55
+ PseudoCleaner::MasterCleaner.peek_data_new_test("PseudoCleaner::peek_data - #{report_name}")
56
+ end
57
+ end
58
+ else
59
+ if PseudoCleaner::SpinachErrorHandler.exception
60
+ if PseudoCleaner::Configuration.instance.peek_data_on_error
61
+ PseudoCleaner::MasterCleaner.peek_data_inline("PseudoCleaner::peek_data - #{report_name}")
62
+ end
63
+ else
64
+ if PseudoCleaner::Configuration.instance.peek_data_not_on_error
65
+ PseudoCleaner::MasterCleaner.peek_data_new_test("PseudoCleaner::peek_data - #{report_name}")
66
+ end
67
+ end
68
+ end
69
+
70
+ PseudoCleaner::MasterCleaner.end_example(scenario_data, "PseudoCleaner::end_test - #{report_name}")
71
+ PseudoCleaner::SpinachErrorHandler.exception = nil
34
72
  end
35
73
  end
36
74
 
75
+ Spinach.hooks.on_failed_step do |step_data, exception, location, step_definitions|
76
+ PseudoCleaner::SpinachErrorHandler.exception = exception
77
+ end
78
+
79
+ Spinach.hooks.on_error_step do |step_data, exception, location, step_definitions|
80
+ PseudoCleaner::SpinachErrorHandler.exception = exception
81
+ end
82
+
37
83
  Spinach.hooks.after_run do |status|
38
84
  # We end suite in case a custom cleaner wants/needs to.
39
85
  PseudoCleaner::MasterCleaner.end_suite
@@ -78,30 +78,58 @@ module PseudoCleaner
78
78
  save_state
79
79
  end
80
80
 
81
+ def within_report_block(description, conditional, &block)
82
+ @report_table = nil
83
+
84
+ if PseudoCleaner::MasterCleaner.report_table || conditional
85
+ Cornucopia::Util::ReportTable.new(nested_table: PseudoCleaner::MasterCleaner.report_table,
86
+ nested_table_label: description,
87
+ suppress_blank_table: true) do |sub_report|
88
+ @report_table = sub_report
89
+
90
+ block.yield
91
+ end
92
+ else
93
+ block.yield
94
+ end
95
+
96
+ @report_table = nil
97
+ end
98
+
81
99
  def save_state
82
100
  initial_state = @@initial_states[@table]
83
101
 
84
102
  if @test_strategy == :pseudo_delete && !initial_state[:saved]
85
103
  initial_state[:saved] = true
86
104
 
87
- if @options[:output_diagnostics]
88
- PseudoCleaner::Logger.write(" Gathering information about \"#{initial_state[:table_name]}\"...".blue.on_light_white)
89
- end
105
+ within_report_block(initial_state[:table_name], @options[:output_diagnostics]) do
106
+ if @options[:output_diagnostics]
107
+ PseudoCleaner::MasterCleaner.report_error
90
108
 
91
- if initial_state[:table_is_active_record]
92
- test_start_active_record @test_strategy
93
- end
109
+ unless @report_table
110
+ PseudoCleaner::Logger.write(" Gathering information about \"#{initial_state[:table_name]}\"...".blue.on_light_white)
111
+ end
112
+ end
94
113
 
95
- if initial_state[:table_is_sequel_model]
96
- test_start_sequel_model @test_strategy
97
- end
114
+ if initial_state[:table_is_active_record]
115
+ test_start_active_record @test_strategy
116
+ end
98
117
 
99
- if PseudoCleaner::Configuration.current_instance.reset_auto_increment
100
- reset_auto_increment !PseudoCleaner::Configuration.current_instance.clean_database_before_tests
101
- end
118
+ if initial_state[:table_is_sequel_model]
119
+ test_start_sequel_model @test_strategy
120
+ end
102
121
 
103
- if initial_state.has_key?(:count) && @options[:output_diagnostics]
104
- PseudoCleaner::Logger.write(" *** There are no columns to track inserts and updates easily on for #{initial_state[:table_name]} ***".red.on_light_white)
122
+ if PseudoCleaner::Configuration.current_instance.reset_auto_increment
123
+ reset_auto_increment !PseudoCleaner::Configuration.current_instance.clean_database_before_tests
124
+ end
125
+
126
+ if initial_state.has_key?(:count) && @options[:output_diagnostics]
127
+ if @report_table
128
+ @report_table.write_stats "", "*** There are no columns to track inserts and updates easily on for #{initial_state[:table_name]} ***"
129
+ else
130
+ PseudoCleaner::Logger.write(" *** There are no columns to track inserts and updates easily on for #{initial_state[:table_name]} ***".red.on_light_white)
131
+ end
132
+ end
105
133
  end
106
134
  end
107
135
  end
@@ -125,7 +153,14 @@ module PseudoCleaner
125
153
  if PseudoCleaner::Configuration.db_connection(:active_record).connection.columns(table_name).find { |column| column.name == "id" }
126
154
  new_state[:max_id] = PseudoCleaner::Configuration.db_connection(:active_record).connection.
127
155
  execute("SELECT MAX(`id`) FROM `#{table_name}`").first[0] || 0
128
- PseudoCleaner::Logger.write(" max(id) = #{new_state[:max_id]}") if @options[:output_diagnostics]
156
+
157
+ if @options[:output_diagnostics]
158
+ if @report_table
159
+ @report_table.write_stats("max(id)", new_state[:max_id])
160
+ else
161
+ PseudoCleaner::Logger.write(" max(id) = #{new_state[:max_id]}")
162
+ end
163
+ end
129
164
  end
130
165
 
131
166
  [:created, :updated].each do |date_name|
@@ -134,14 +169,19 @@ module PseudoCleaner
134
169
 
135
170
  if PseudoCleaner::Configuration.db_connection(:active_record).connection.
136
171
  columns(table_name).find { |column| column.name == date_column_name }
137
- new_state[date_name] = {
172
+ new_state[date_name] = {
138
173
  column_name: date_column_name,
139
174
  value: PseudoCleaner::Configuration.db_connection(:active_record).connection.
140
175
  execute("SELECT MAX(`#{date_column_name}`) FROM `#{table_name}`").first[0] ||
141
176
  Time.now - 1.second
142
177
  }
178
+ new_state[date_name][:initial_value] = new_state[date_name][:value]
143
179
  if @options[:output_diagnostics]
144
- PseudoCleaner::Logger.write(" max(#{new_state[date_name][:column_name]}) = #{new_state[date_name][:value]}")
180
+ if @report_table
181
+ @report_table.write("max(#{new_state[date_name][:column_name]})", new_state[date_name][:value])
182
+ else
183
+ PseudoCleaner::Logger.write(" max(#{new_state[date_name][:column_name]}) = #{new_state[date_name][:value]}")
184
+ end
145
185
  end
146
186
 
147
187
  break
@@ -162,7 +202,13 @@ module PseudoCleaner
162
202
 
163
203
  if access_table.columns.include?(:id)
164
204
  new_state[:max_id] = access_table.unfiltered.max(:id) || 0
165
- PseudoCleaner::Logger.write(" max(id) = #{new_state[:max_id]}") if @options[:output_diagnostics]
205
+ if @options[:output_diagnostics]
206
+ if @report_table
207
+ @report_table.write_stats("max(id)", new_state[:max_id])
208
+ else
209
+ PseudoCleaner::Logger.write(" max(id) = #{new_state[:max_id]}")
210
+ end
211
+ end
166
212
  end
167
213
 
168
214
  [:created, :updated].each do |date_name|
@@ -170,12 +216,17 @@ module PseudoCleaner
170
216
  date_column_name = "#{date_name}_#{verb_name}".to_sym
171
217
 
172
218
  if access_table.columns.include?(date_column_name)
173
- new_state[date_name] = {
219
+ new_state[date_name] = {
174
220
  column_name: date_column_name,
175
221
  value: access_table.unfiltered.max(date_column_name) || Time.now - 1.second
176
222
  }
223
+ new_state[date_name][:initial_value] = new_state[date_name][:value]
177
224
  if @options[:output_diagnostics]
178
- PseudoCleaner::Logger.write(" max(#{new_state[date_name][:column_name]}) = #{new_state[date_name][:value]}")
225
+ if @report_table
226
+ @report_table.write_stats("max(#{new_state[date_name][:column_name]})", new_state[date_name][:value])
227
+ else
228
+ PseudoCleaner::Logger.write(" max(#{new_state[date_name][:column_name]}) = #{new_state[date_name][:value]}")
229
+ end
179
230
  end
180
231
 
181
232
  break
@@ -190,23 +241,37 @@ module PseudoCleaner
190
241
  end
191
242
 
192
243
  def test_end test_strategy
193
- reset_table test_strategy, false
244
+ initial_state = @@initial_states[@table]
245
+
246
+ within_report_block(initial_state[:table_name], @options[:output_diagnostics]) do
247
+ reset_table test_strategy, false, false
248
+ end
194
249
  end
195
250
 
196
251
  def suite_end test_strategy
197
- reset_table test_strategy, true
252
+ initial_state = @@initial_states[@table]
253
+
254
+ within_report_block(initial_state[:table_name], @options[:output_diagnostics]) do
255
+ reset_table test_strategy, true, true
256
+ end
198
257
  end
199
258
 
200
- def reset_table test_strategy, require_output
259
+ def reset_table test_strategy, require_output, is_suite_end
260
+ initial_state = @@initial_states[@table]
261
+
201
262
  if @test_strategy != test_strategy && !PseudoCleaner::Configuration.current_instance.single_cleaner_set
202
263
  if @options[:output_diagnostics]
203
- PseudoCleaner::Logger.write(" *** The ending strategy for \"#{initial_state[:table_name]}\" changed! ***".red.on_light_white)
264
+ PseudoCleaner::MasterCleaner.report_error
265
+
266
+ if @report_table
267
+ @report_table.write_stats("WARNING", "*** The ending strategy for \"#{initial_state[:table_name]}\" changed! ***")
268
+ else
269
+ PseudoCleaner::Logger.write(" *** The ending strategy for \"#{initial_state[:table_name]}\" changed! ***".red.on_light_white)
270
+ end
204
271
  end
205
272
  end
206
273
 
207
274
  if test_strategy == :pseudo_delete || PseudoCleaner::Configuration.current_instance.post_transaction_analysis
208
- initial_state = @@initial_states[@table]
209
-
210
275
  # we should check the relationships for any records which still refer to
211
276
  # a now deleted record. (i.e. if we updated a record to refer to a record)
212
277
  # we deleted...
@@ -216,23 +281,23 @@ module PseudoCleaner
216
281
  # I'm using it because it is faster than reseeding each test...
217
282
  # And, I can be responsible for worrying about referential integrity in the test
218
283
  # if I want to...
219
- pre_string = " Resetting table \"#{initial_state[:table_name]}\" for #{test_strategy}..."
220
- pre_string = "Tests ended without cleaning up properly!!!\n" + pre_string if require_output
221
- pre_string = pre_string.red.on_light_white if require_output
284
+ pre_string = " Resetting table \"#{initial_state[:table_name]}\" for #{test_strategy}..."
285
+ pre_string = "Tests ended without cleaning up properly!!!\n" + pre_string if require_output
286
+ pre_string = pre_string.red.on_light_white if require_output
222
287
 
223
288
  require_output ||= @options[:output_diagnostics]
224
289
 
225
290
  if initial_state[:table_is_active_record]
226
- test_end_active_record test_strategy, pre_string, require_output
291
+ test_end_active_record test_strategy, pre_string, require_output, is_suite_end
227
292
  end
228
293
 
229
294
  if initial_state[:table_is_sequel_model]
230
- test_end_sequel_model test_strategy, pre_string, require_output
295
+ test_end_sequel_model test_strategy, pre_string, require_output, is_suite_end
231
296
  end
232
297
  end
233
298
  end
234
299
 
235
- def test_end_active_record test_strategy, pre_string, require_output
300
+ def test_end_active_record test_strategy, pre_string, require_output, is_suite_end
236
301
  initial_state = @@initial_states[@table]
237
302
  cleaned_table = false
238
303
 
@@ -249,6 +314,8 @@ module PseudoCleaner
249
314
 
250
315
  pre_string = output_delete_record(test_strategy,
251
316
  " Deleted #{num_deleted} records by ID.",
317
+ "Deleted",
318
+ "#{num_deleted} records by ID",
252
319
  pre_string,
253
320
  require_output)
254
321
  end
@@ -264,16 +331,23 @@ module PseudoCleaner
264
331
 
265
332
  pre_string = output_delete_record(test_strategy,
266
333
  " Deleted #{num_deleted} records by #{initial_state[:created][:column_name]}.",
334
+ "Deleted",
335
+ "#{num_deleted} records by #{initial_state[:created][:column_name]}",
267
336
  pre_string,
268
337
  require_output)
269
338
  end
270
339
  end
271
340
 
272
- if initial_state[:updated]
341
+ if initial_state[:updated] && !ignore_updates
342
+ test_value = initial_state[:updated][:value]
343
+ if is_suite_end
344
+ test_value = initial_state[:updated][:initial_value]
345
+ end
346
+
273
347
  dirty_count = PseudoCleaner::Configuration.db_connection(:active_record).connection.
274
- execute("SELECT COUNT(*) FROM `#{table_name}` WHERE #{initial_state[:updated][:column_name]} > '#{initial_state[:updated][:value]}'").first[0]
348
+ execute("SELECT COUNT(*) FROM `#{table_name}` WHERE #{initial_state[:updated][:column_name]} > '#{test_value}'").first[0]
275
349
 
276
- if require_output && dirty_count > 0
350
+ if dirty_count > 0
277
351
  # cleaned_table = true
278
352
 
279
353
  initial_state[:updated][:value] = PseudoCleaner::Configuration.db_connection(:active_record).connection.
@@ -281,6 +355,8 @@ module PseudoCleaner
281
355
 
282
356
  pre_string = output_delete_record(test_strategy,
283
357
  " *** There are #{dirty_count} records which have been updated and may be dirty remaining after cleaning \"#{initial_state[:table_name]}\"... ***".red.on_light_white,
358
+ "WARNING",
359
+ "*** There are #{dirty_count} records which have been updated and may be dirty remaining after cleaning \"#{initial_state[:table_name]}\"... ***",
284
360
  pre_string,
285
361
  require_output)
286
362
  end
@@ -297,6 +373,8 @@ module PseudoCleaner
297
373
  if final_count > 0
298
374
  pre_string = output_delete_record(test_strategy,
299
375
  " Deleted #{final_count} records by cleaning the table.",
376
+ "Deleted",
377
+ "#{final_count} records by cleaning the table",
300
378
  pre_string,
301
379
  require_output)
302
380
  end
@@ -309,6 +387,8 @@ module PseudoCleaner
309
387
  if initial_state[:count] != final_count
310
388
  pre_string = output_delete_record(test_strategy,
311
389
  " *** There are #{final_count - initial_state[:count]} dirty records remaining after cleaning \"#{initial_state[:table_name]}\"... ***".red.on_light_white,
390
+ "WARNING",
391
+ "*** There are #{final_count - initial_state[:count]} dirty records remaining after cleaning \"#{initial_state[:table_name]}\"... ***",
312
392
  pre_string,
313
393
  true)
314
394
 
@@ -321,7 +401,11 @@ module PseudoCleaner
321
401
  end
322
402
  end
323
403
 
324
- def test_end_sequel_model test_strategy, pre_string, require_output
404
+ def ignore_updates
405
+ false
406
+ end
407
+
408
+ def test_end_sequel_model test_strategy, pre_string, require_output, is_suite_end
325
409
  initial_state = @@initial_states[@table]
326
410
  access_table = sequel_model_table
327
411
  cleaned_table = false
@@ -335,6 +419,8 @@ module PseudoCleaner
335
419
 
336
420
  pre_string = output_delete_record(test_strategy,
337
421
  " Deleted #{num_deleted} records by ID.",
422
+ "Deleted",
423
+ "#{num_deleted} records by ID",
338
424
  pre_string,
339
425
  require_output)
340
426
  end
@@ -350,24 +436,33 @@ module PseudoCleaner
350
436
 
351
437
  pre_string = output_delete_record(test_strategy,
352
438
  " Deleted #{num_deleted} records by #{initial_state[:created][:column_name]}.",
439
+ "Deleted",
440
+ "#{num_deleted} records by #{initial_state[:created][:column_name]}",
353
441
  pre_string,
354
442
  require_output)
355
443
  end
356
444
  end
357
445
 
358
- if initial_state[:updated]
446
+ if initial_state[:updated] && !ignore_updates
447
+ test_value = initial_state[:updated][:value]
448
+ if is_suite_end
449
+ test_value = initial_state[:updated][:initial_value]
450
+ end
451
+
359
452
  dirty_count = access_table.
360
453
  unfiltered.
361
- where("`#{initial_state[:updated][:column_name]}` > ?", initial_state[:updated][:value]).
454
+ where("`#{initial_state[:updated][:column_name]}` > ?", test_value).
362
455
  count
363
456
 
364
- if require_output && dirty_count > 0
457
+ if dirty_count > 0
365
458
  # cleaned_table = true
366
459
 
367
460
  initial_state[:updated][:value] = access_table.unfiltered.max(initial_state[:updated][:column_name])
368
461
 
369
462
  pre_string = output_delete_record(test_strategy,
370
463
  " *** There are #{dirty_count} records which have been updated and may be dirty remaining after cleaning \"#{initial_state[:table_name]}\"... ***".red.on_light_white,
464
+ "WARNING",
465
+ "*** There are #{dirty_count} records which have been updated and may be dirty remaining after cleaning \"#{initial_state[:table_name]}\"... ***",
371
466
  pre_string,
372
467
  require_output)
373
468
  end
@@ -383,6 +478,8 @@ module PseudoCleaner
383
478
  if final_count > 0
384
479
  pre_string = output_delete_record(test_strategy,
385
480
  " Deleted #{final_count} records by cleaning the table.",
481
+ "Deleted",
482
+ "#{final_count} records by cleaning the table",
386
483
  pre_string,
387
484
  require_output)
388
485
  end
@@ -394,6 +491,8 @@ module PseudoCleaner
394
491
  if initial_state[:count] != final_count
395
492
  pre_string = output_delete_record(test_strategy,
396
493
  " *** There are #{final_count - initial_state[:count]} dirty records remaining after cleaning \"#{initial_state[:table_name]}\"... ***".red.on_light_white,
494
+ "WARNING",
495
+ "*** There are #{final_count - initial_state[:count]} dirty records remaining after cleaning \"#{initial_state[:table_name]}\"... ***",
397
496
  pre_string,
398
497
  true)
399
498
 
@@ -407,12 +506,29 @@ module PseudoCleaner
407
506
  end
408
507
  end
409
508
 
410
- def output_delete_record(test_strategy, stats_string, pre_string, require_output = false)
411
- PseudoCleaner::Logger.write(pre_string) if pre_string && (@options[:output_diagnostics] || require_output)
509
+ def output_delete_record(test_strategy,
510
+ stats_string,
511
+ table_label,
512
+ table_value,
513
+ pre_string,
514
+ require_output = false)
515
+ if pre_string && !@report_table && (@options[:output_diagnostics] || require_output)
516
+ PseudoCleaner::Logger.write(pre_string)
517
+ end
518
+
412
519
  if test_strategy == :transaction
413
520
  PseudoCleaner::Logger.write(" ***** TRANSACTION FAILED!!! *****".red.on_light_white)
414
521
  end
415
- PseudoCleaner::Logger.write(stats_string) if @options[:output_diagnostics] || require_output
522
+
523
+ if @options[:output_diagnostics] || require_output
524
+ PseudoCleaner::MasterCleaner.report_error
525
+
526
+ if @report_table
527
+ @report_table.write_stats(table_label, table_value)
528
+ else
529
+ PseudoCleaner::Logger.write(stats_string)
530
+ end
531
+ end
416
532
 
417
533
  nil
418
534
  end
@@ -439,7 +555,11 @@ module PseudoCleaner
439
555
 
440
556
  unless table_name.blank?
441
557
  if @options[:output_diagnostics]
442
- PseudoCleaner::Logger.write(" ALTER TABLE #{table_name} AUTO_INCREMENT = #{initial_state[:max_id] + 1}")
558
+ if @report_table
559
+ @report_table.write_stats("AUTO_INCREMENT", initial_state[:max_id] + 1)
560
+ else
561
+ PseudoCleaner::Logger.write(" ALTER TABLE #{table_name} AUTO_INCREMENT = #{initial_state[:max_id] + 1}")
562
+ end
443
563
  end
444
564
 
445
565
  PseudoCleaner::Configuration.db_connection(:active_record).connection.
@@ -456,7 +576,11 @@ module PseudoCleaner
456
576
 
457
577
  unless table_name.blank?
458
578
  if @options[:output_diagnostics]
459
- PseudoCleaner::Logger.write(" ALTER TABLE #{table_name} AUTO_INCREMENT = #{initial_state[:max_id] + 1}")
579
+ if @report_table
580
+ @report_table.write_stats("AUTO_INCREMENT", initial_state[:max_id] + 1)
581
+ else
582
+ PseudoCleaner::Logger.write(" ALTER TABLE #{table_name} AUTO_INCREMENT = #{initial_state[:max_id] + 1}")
583
+ end
460
584
  end
461
585
 
462
586
  PseudoCleaner::Configuration.db_connection(:sequel)["ALTER TABLE #{table_name} AUTO_INCREMENT = #{initial_state[:max_id] + 1}"].first
@@ -577,7 +701,7 @@ module PseudoCleaner
577
701
  elsif initial_state[:updated]
578
702
  dataset = sequel_model_table.
579
703
  unfiltered.
580
- where("`#{initial_state[:updated][:column_name]}` > ?", initial_state[:created][:value])
704
+ where("`#{initial_state[:updated][:column_name]}` > ?", initial_state[:updated][:value])
581
705
  elsif initial_state[:count]
582
706
  dataset = sequel_model_table.unfiltered.limit(99, initial_state[:count])
583
707
  end
@@ -588,5 +712,37 @@ module PseudoCleaner
588
712
  end
589
713
  end
590
714
  end
715
+
716
+ def peek_values
717
+ row_data = []
718
+ peek_name = nil
719
+
720
+ review_rows do |table_name, table_values|
721
+ peek_name = table_name
722
+ row_data << table_values
723
+ end
724
+
725
+ if row_data && !row_data.empty?
726
+ output_values = false
727
+
728
+ if PseudoCleaner::MasterCleaner.report_table
729
+ Cornucopia::Util::ReportTable.new(nested_table: PseudoCleaner::MasterCleaner.report_table,
730
+ nested_table_label: peek_name,
731
+ suppress_blank_table: true) do |report_table|
732
+ row_data.each_with_index do |row, row_index|
733
+ report_table.write_stats row_index.to_s, row
734
+ end
735
+ end
736
+ else
737
+ PseudoCleaner::Logger.write(" #{peek_name}")
738
+
739
+ row_data.each do |updated_value|
740
+ PseudoCleaner::Logger.write(" #{updated_value}")
741
+ end
742
+ end
743
+
744
+ PseudoCleaner::MasterCleaner.report_error
745
+ end
746
+ end
591
747
  end
592
748
  end