refactoring (#116)

- refactoring architecture
- fix incomplete ssh logs
- code editor for scripts in the app
- remove Jobs and SSHCommands
This commit is contained in:
Saeed Vaziry
2024-03-14 20:03:43 +01:00
committed by GitHub
parent cee4a70c3c
commit 428140b931
472 changed files with 24110 additions and 8159 deletions

View File

@ -7,11 +7,10 @@
use App\Enums\ServerProvider;
use App\Enums\ServerStatus;
use App\Enums\ServerType;
use App\Enums\ServiceStatus;
use App\Enums\Webserver;
use App\Jobs\Installation\Initialize;
use App\Facades\SSH;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Bus;
use JsonException;
use Tests\TestCase;
/**
@ -21,14 +20,11 @@ class ServerTest extends TestCase
{
use RefreshDatabase;
/**
* @throws JsonException
*/
public function test_create_custom_server(): void
{
$this->actingAs($this->user);
Bus::fake();
SSH::fake('Active: active'); // fake output for service installations
$this->post(route('servers.create'), [
'type' => ServerType::REGULAR,
@ -40,14 +36,57 @@ public function test_create_custom_server(): void
'webserver' => Webserver::NGINX,
'database' => Database::MYSQL80,
'php' => '8.2',
])->assertSessionHasNoErrors();
])->assertSessionDoesntHaveErrors();
$this->assertDatabaseHas('servers', [
'name' => 'test',
'ip' => '1.1.1.1',
'status' => ServerStatus::INSTALLING,
'status' => ServerStatus::READY,
]);
Bus::assertDispatched(Initialize::class);
$this->assertDatabaseHas('services', [
'server_id' => 1,
'type' => 'php',
'version' => '8.2',
'status' => ServiceStatus::READY,
]);
$this->assertDatabaseHas('services', [
'server_id' => 1,
'type' => 'webserver',
'name' => 'nginx',
'version' => 'latest',
'status' => ServiceStatus::READY,
]);
$this->assertDatabaseHas('services', [
'server_id' => 1,
'type' => 'database',
'name' => 'mysql',
'version' => '8.0',
'status' => ServiceStatus::READY,
]);
$this->assertDatabaseHas('services', [
'server_id' => 1,
'type' => 'firewall',
'name' => 'ufw',
'version' => 'latest',
'status' => ServiceStatus::READY,
]);
}
public function test_delete_server(): void
{
$this->actingAs($this->user);
SSH::fake();
$this->delete(route('servers.delete', $this->server))
->assertSessionDoesntHaveErrors();
$this->assertDatabaseMissing('servers', [
'id' => $this->server->id,
]);
}
}