mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
test
This commit is contained in:
45
tests/Feature/ConsoleTest.php
Normal file
45
tests/Feature/ConsoleTest.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Facades\SSH;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ConsoleTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_see_console(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->get(route('servers.console', $this->server))
|
||||
->assertSeeText('Headless Console');
|
||||
}
|
||||
|
||||
public function test_run(): void
|
||||
{
|
||||
SSH::fake('fake output');
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->post(route('servers.console.run', $this->server), [
|
||||
'user' => 'vito',
|
||||
'command' => 'ls -la',
|
||||
])->assertStreamedContent('fake output');
|
||||
}
|
||||
|
||||
public function test_run_validation_error(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->post(route('servers.console.run', $this->server), [
|
||||
'user' => 'vito',
|
||||
])->assertSessionHasErrors('command');
|
||||
|
||||
$this->post(route('servers.console.run', $this->server), [
|
||||
'command' => 'ls -la',
|
||||
])->assertSessionHasErrors('user');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user