Skip to content

Commit 5b4c16f

Browse files
committed
use a helper function for clearing the disk
1 parent 0ac1e46 commit 5b4c16f

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

tests/Commands/CleanupTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
it('can delete old snapshots keeping the desired number of snapshots', function () {
66
// Add sleep to make sure files do not have the same modified time.
77
// They may not sort properly if all have the same timestamp.
8-
$this->clearDisk();
8+
clearDisk();
99

1010
$this->disk->put('snapshot1.sql', 'new content');
1111

@@ -20,7 +20,7 @@
2020
});
2121

2222
it('can delete all snapshots if keep is zero', function () {
23-
$this->clearDisk();
23+
clearDisk();
2424

2525
$this->disk->put('snapshot.sql', 'new content');
2626

@@ -30,7 +30,7 @@
3030
});
3131

3232
it('warns if keep is not specified', function () {
33-
$this->clearDisk();
33+
clearDisk();
3434

3535
$this->disk->put('snapshot.sql', 'new content');
3636

tests/Pest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050

5151
// Functions
5252

53+
function clearDisk(): void
54+
{
55+
test()->disk->delete(test()->disk->allFiles());
56+
}
57+
5358
function seeInConsoleOutput(string|array $searchStrings): void
5459
{
5560
if (!is_array($searchStrings)) {

tests/TestCase.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,10 @@ protected function setUpDisk()
8686
{
8787
$this->disk = app(Factory::class)->disk('snapshots');
8888

89-
$this->clearDisk();
89+
clearDisk();
9090
$this->createDummySnapshots();
9191
}
9292

93-
protected function clearDisk()
94-
{
95-
$this->disk->delete($this->disk->allFiles());
96-
}
97-
9893
protected function createDummySnapshots()
9994
{
10095
foreach (range(1, 3) as $i) {

0 commit comments

Comments
 (0)