From 87b6ebaab229a4901ad5d44dbfc24dc988fdd454 Mon Sep 17 00:00:00 2001 From: asciito Date: Fri, 1 Dec 2023 11:54:42 -0600 Subject: [PATCH] Add code to delete the Google testing directory --- app/Commands/DriverManagerCommand.php | 8 ++++++-- tests/Feature/ManageDriverCommandTest.php | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/Commands/DriverManagerCommand.php b/app/Commands/DriverManagerCommand.php index af6c142..fa4b185 100644 --- a/app/Commands/DriverManagerCommand.php +++ b/app/Commands/DriverManagerCommand.php @@ -7,6 +7,7 @@ use Illuminate\Console\Command; use Illuminate\Contracts\Process\ProcessResult; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Process; use Illuminate\Support\Str; @@ -307,10 +308,13 @@ protected function getBinary(): string protected function getChromeDriverDirectory(): string { + $directory = join_paths(getenv('HOME'), '.google-for-testing'); + + File::ensureDirectoryExists($directory); + return $this->option('path') ?? join_paths( - getenv('HOME'), - '.google-for-testing', + $directory, 'chromedriver-'.$this->platforms[OperatingSystem::id()], ); } diff --git a/tests/Feature/ManageDriverCommandTest.php b/tests/Feature/ManageDriverCommandTest.php index 3e1db3b..283cb64 100644 --- a/tests/Feature/ManageDriverCommandTest.php +++ b/tests/Feature/ManageDriverCommandTest.php @@ -5,10 +5,13 @@ use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Process; use Illuminate\Support\Str; +use Illuminate\Support\Facades\File; use Laravel\Prompts\Prompt; use function Pest\Laravel\artisan; +afterAll(fn () => File::deleteDirectory(join_paths(getenv('HOME'), '.google-for-testing'))); + it('start a Chrome Driver server', function () { Process::fake();