File tree Expand file tree Collapse file tree 2 files changed +27
-27
lines changed Expand file tree Collapse file tree 2 files changed +27
-27
lines changed Original file line number Diff line number Diff line change 77
88class Cleanup extends Command
99{
10- protected $ signature = 'snapshot:cleanup {--keep=} ' ;
10+ protected $ signature = 'snapshot:cleanup {--keep=} ' ;
1111
12- protected $ description = 'Specify how many snapshots to keep and delete the rest ' ;
12+ protected $ description = 'Specify how many snapshots to keep and delete the rest ' ;
1313
14- public function handle ()
15- {
16- $ snapshots = app (SnapshotRepository::class)->getAll ();
14+ public function handle ()
15+ {
16+ $ snapshots = app (SnapshotRepository::class)->getAll ();
1717
18- $ keep = $ this ->option ('keep ' );
18+ $ keep = $ this ->option ('keep ' );
1919
20- if (!$ this ->option ('keep ' )) {
21- $ this ->warn ('No value for option --keep. ' );
20+ if (!$ this ->option ('keep ' )) {
21+ $ this ->warn ('No value for option --keep. ' );
2222
23- return ;
24- }
23+ return ;
24+ }
2525
26- $ snapshots ->splice ($ keep )->each (function ($ snapshot ) {
27- $ snapshot ->delete ();
28- });
29- }
26+ $ snapshots ->splice ($ keep )->each (function ($ snapshot ) {
27+ $ snapshot ->delete ();
28+ });
29+ }
3030}
Original file line number Diff line number Diff line change 77
88class CleanupTest extends TestCase
99{
10- /** @test */
11- public function it_can_delete_old_snapshots_keeping_the_desired_number_of_snapshots ()
12- {
13- // Add sleep to make sure files do not have the same modified time.
14- // They may not sort properly if all have the same timestamp.
15- $ this ->clearDisk ();
10+ /** @test */
11+ public function it_can_delete_old_snapshots_keeping_the_desired_number_of_snapshots ()
12+ {
13+ // Add sleep to make sure files do not have the same modified time.
14+ // They may not sort properly if all have the same timestamp.
15+ $ this ->clearDisk ();
1616
17- $ this ->disk ->put ('snapshot1.sql ' , 'new content ' );
17+ $ this ->disk ->put ('snapshot1.sql ' , 'new content ' );
1818
19- sleep (1 );
19+ sleep (1 );
2020
21- $ this ->disk ->put ('snapshot2.sql ' , 'new content ' );
21+ $ this ->disk ->put ('snapshot2.sql ' , 'new content ' );
2222
23- Artisan::call ('snapshot:cleanup ' , ['--keep ' => 1 ]);
23+ Artisan::call ('snapshot:cleanup ' , ['--keep ' => 1 ]);
2424
25- $ this ->disk ->assertMissing ('snapshot1.sql ' );
26- $ this ->disk ->assertExists ('snapshot2.sql ' );
27- }
25+ $ this ->disk ->assertMissing ('snapshot1.sql ' );
26+ $ this ->disk ->assertExists ('snapshot2.sql ' );
27+ }
2828}
You can’t perform that action at this time.
0 commit comments