Skip to content

Commit

Permalink
add preview of server to kill action
Browse files Browse the repository at this point in the history
Also, and change the text for `kill` and `list` action
  • Loading branch information
asciito committed Oct 23, 2023
1 parent 73e1baf commit 12a42a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/Commands/DriverManagerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public function handle(): int
'stop' => 'Stop a server',
'restart' => 'Restart a server',
'status' => 'Status of a server',
'list' => 'List all the server available in the system',
'kill' => 'Kill all the servers available in the system',
'list' => 'List all the server',
'kill' => 'Kill all the servers',
]);
$callable = match ($action) {
Expand Down Expand Up @@ -179,6 +179,8 @@ protected function kill(): int
return self::FAILURE;
}

$this->table(['PID', 'PORT'], $pids);

if (! $this->confirm('Are you sure you want to do this?')) {
return self::SUCCESS;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/Feature/ManageDriverCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@
]);

artisan('manage:driver', ['action' => 'kill'])
->expectsTable(['PID', 'PORT'], collect($data)->map(function (string $value) {
$values = explode(" ", $value);

return ['pid' => $values[0], 'port' => $values[1]];
}))
->expectsConfirmation('Are you sure you want to do this?', 'yes')
->expectsOutputToContain('Stopping all the Google Chrome Driver servers that are available in the system')
->expectsOutputToContain('Stopping Google Chrome Driver [PID: 9991]')
Expand Down

0 comments on commit 12a42a1

Please sign in to comment.