Files
vito/tests/Unit/Actions/Service/UninstallTest.php
Rasel Islam Rafi 984c1f3a8e Add Caddy Server Support Alongside Nginx (#600)
* added enum

* add config for caddy

* add svg icon

* add caddy service class

* wip

* install caddy

* create base Caddyfile with common snippets

* Create a systemd service to run Caddy in the background.

* create uninstall file

* wip

* create path

* create vhost

* get vhost

* delete site

* add php version change file

* add custom ssl

* create redirect file

* add vhost for caddy site & load balancer

* update svg

* fix caddy icon

* fix style

* add systemctl reload method

* Reload systemd after modifying the Caddy service file.

* add caddy

* added tests

* format with pint

* prevent multiple web server installations

* added error log & access log

(cherry picked from commit 2318e1b1df)
2025-05-29 11:39:00 +02:00

99 lines
2.4 KiB
PHP

<?php
namespace Tests\Unit\Actions\Service;
use App\Actions\Service\Uninstall;
use App\Enums\ServiceStatus;
use App\Facades\SSH;
use App\Models\Database;
use App\Models\Service;
use App\Models\Worker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Validation\ValidationException;
use Tests\TestCase;
class UninstallTest extends TestCase
{
use RefreshDatabase;
public function test_uninstall_vito_agent(): void
{
SSH::fake();
Service::factory()->create([
'server_id' => $this->server->id,
'name' => 'vito-agent',
'type' => 'monitoring',
'version' => 'latest',
'status' => ServiceStatus::READY,
]);
app(Uninstall::class)->uninstall($this->server->monitoring());
$this->assertDatabaseMissing('services', [
'server_id' => $this->server->id,
'name' => 'vito-agent',
'type' => 'monitoring',
'version' => 'latest',
'status' => ServiceStatus::READY,
]);
}
/**
* Cannot uninstall nginx because some sites using it
*/
public function test_cannot_uninstall_nginx(): void
{
SSH::fake();
$this->expectException(ValidationException::class);
app(Uninstall::class)->uninstall($this->server->webserver());
}
/**
* Cannot uninstall caddy because some sites using it
*/
public function test_cannot_uninstall_caddy(): void
{
SSH::fake();
$this->expectException(ValidationException::class);
app(Uninstall::class)->uninstall($this->server->webserver());
}
/**
* Cannot uninstall mysql because some databases exist
*/
public function test_cannot_uninstall_mysql(): void
{
SSH::fake();
Database::factory()->create([
'server_id' => $this->server->id,
]);
$this->expectException(ValidationException::class);
app(Uninstall::class)->uninstall($this->server->database());
}
/**
* Cannot uninstall supervisor because some queues exist
*/
public function test_cannot_uninstall_supervisor(): void
{
SSH::fake();
Worker::factory()->create([
'server_id' => $this->server->id,
'site_id' => $this->site->id,
]);
$this->expectException(ValidationException::class);
app(Uninstall::class)->uninstall($this->server->processManager());
}
}