cleanup before release (#391)

This commit is contained in:
Saeed Vaziry
2024-12-13 20:02:43 +01:00
committed by GitHub
parent d91fa4061c
commit 0d12dd0c69
27 changed files with 649 additions and 899 deletions

View File

@ -43,10 +43,7 @@ public function test_get_server(): void
]);
}
/**
* @dataProvider createData
*/
public function test_create_server(string $type): void
public function test_create_server(): void
{
Sanctum::actingAs($this->user, ['read', 'write']);
@ -55,7 +52,6 @@ public function test_create_server(string $type): void
$this->json('POST', route('api.projects.servers.create', [
'project' => $this->user->current_project_id,
]), [
'type' => $type,
'provider' => ServerProvider::CUSTOM,
'name' => 'test',
'ip' => '1.1.1.1',
@ -68,7 +64,7 @@ public function test_create_server(string $type): void
->assertSuccessful()
->assertJsonFragment([
'name' => 'test',
'type' => $type,
'type' => ServerType::REGULAR,
]);
}
@ -110,12 +106,4 @@ public function test_upgrade_server(): void
]))
->assertNoContent();
}
public static function createData(): array
{
return [
[ServerType::REGULAR],
[ServerType::DATABASE],
];
}
}

View File

@ -6,11 +6,9 @@
use App\Enums\OperatingSystem;
use App\Enums\ServerProvider;
use App\Enums\ServerStatus;
use App\Enums\ServerType;
use App\Enums\ServiceStatus;
use App\Enums\Webserver;
use App\Facades\SSH;
use App\Models\Server;
use App\NotificationChannels\Email\NotificationMail;
use App\Web\Pages\Servers\Index;
use App\Web\Pages\Servers\Settings;
@ -36,7 +34,6 @@ public function test_create_regular_server(): void
Livewire::test(Index::class)
->callAction('create', [
'type' => ServerType::REGULAR,
'provider' => ServerProvider::CUSTOM,
'name' => 'test',
'ip' => '1.1.1.1',
@ -86,64 +83,6 @@ public function test_create_regular_server(): void
]);
}
public function test_create_database_server(): void
{
$this->actingAs($this->user);
SSH::fake('Active: active'); // fake output for service installations
Livewire::test(Index::class)
->callAction('create', [
'type' => ServerType::DATABASE,
'provider' => ServerProvider::CUSTOM,
'name' => 'test',
'ip' => '2.2.2.2',
'port' => '22',
'os' => OperatingSystem::UBUNTU22,
'database' => Database::MYSQL80,
])
->assertSuccessful();
$server = Server::query()->where('ip', '2.2.2.2')->first();
$this->assertDatabaseHas('servers', [
'name' => 'test',
'ip' => '2.2.2.2',
'status' => ServerStatus::READY,
]);
$this->assertDatabaseMissing('services', [
'server_id' => $server->id,
'type' => 'php',
'version' => '8.2',
'status' => ServiceStatus::READY,
]);
$this->assertDatabaseMissing('services', [
'server_id' => $server->id,
'type' => 'webserver',
'name' => 'nginx',
'version' => 'latest',
'status' => ServiceStatus::READY,
]);
$this->assertDatabaseHas('services', [
'server_id' => $server->id,
'type' => 'database',
'name' => 'mysql',
'version' => '8.0',
'status' => ServiceStatus::READY,
]);
$this->assertDatabaseHas('services', [
'server_id' => $server->id,
'type' => 'firewall',
'name' => 'ufw',
'version' => 'latest',
'status' => ServiceStatus::READY,
]);
}
public function test_delete_server(): void
{
$this->actingAs($this->user);