|
9 | 9 | let!(:fresh_event) { VCAP::CloudController::Event.make(created_at: 1.day.ago + 1.minute) } |
10 | 10 |
|
11 | 11 | it 'deletes records older than specified days' do |
12 | | - record_cleanup = Database::OldRecordCleanup.new(VCAP::CloudController::Event, 1) |
| 12 | + record_cleanup = Database::OldRecordCleanup.new(VCAP::CloudController::Event, cutoff_age_in_days: 1) |
13 | 13 |
|
14 | 14 | expect do |
15 | 15 | record_cleanup.delete |
|
22 | 22 |
|
23 | 23 | context "when there are no records at all but you're trying to keep at least one" do |
24 | 24 | it "doesn't keep one because there aren't any to keep" do |
25 | | - record_cleanup = Database::OldRecordCleanup.new(VCAP::CloudController::ServiceUsageEvent, 1, keep_at_least_one_record: true) |
| 25 | + record_cleanup = Database::OldRecordCleanup.new(VCAP::CloudController::ServiceUsageEvent, cutoff_age_in_days: 1, keep_at_least_one_record: true) |
26 | 26 |
|
27 | 27 | expect { record_cleanup.delete }.not_to raise_error |
28 | 28 | expect(VCAP::CloudController::ServiceUsageEvent.count).to eq(0) |
|
31 | 31 |
|
32 | 32 | it 'only retrieves the current timestamp from the database once' do |
33 | 33 | expect(VCAP::CloudController::Event.db).to receive(:fetch).with('SELECT CURRENT_TIMESTAMP as now').once.and_call_original |
34 | | - record_cleanup = Database::OldRecordCleanup.new(VCAP::CloudController::Event, 1) |
| 34 | + record_cleanup = Database::OldRecordCleanup.new(VCAP::CloudController::Event, cutoff_age_in_days: 1) |
35 | 35 | record_cleanup.delete |
36 | 36 | end |
37 | 37 |
|
38 | 38 | it 'keeps the last row when :keep_at_least_one_record is true even if it is older than the cutoff date' do |
39 | | - record_cleanup = Database::OldRecordCleanup.new(VCAP::CloudController::Event, 0, keep_at_least_one_record: true) |
| 39 | + record_cleanup = Database::OldRecordCleanup.new(VCAP::CloudController::Event, cutoff_age_in_days: 0, keep_at_least_one_record: true) |
40 | 40 |
|
41 | 41 | expect do |
42 | 42 | record_cleanup.delete |
|
0 commit comments