mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-05 07:52:34 +00:00
#591 - tests
This commit is contained in:
@ -21,7 +21,9 @@ public function test_install_vito_agent(): void
|
||||
'https://api.github.com/repos/vitodeploy/agent/tags' => Http::response([['name' => '0.1.0']]),
|
||||
]);
|
||||
|
||||
$service = app(Install::class)->install($this->server, [
|
||||
$this->server->monitoring()->delete();
|
||||
|
||||
app(Install::class)->install($this->server, [
|
||||
'type' => 'monitoring',
|
||||
'name' => 'vito-agent',
|
||||
'version' => 'latest',
|
||||
@ -34,12 +36,11 @@ public function test_install_vito_agent(): void
|
||||
'version' => '0.1.0',
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
|
||||
$this->assertNotNull($service->type_data);
|
||||
}
|
||||
|
||||
public function test_install_vito_agent_failed(): void
|
||||
{
|
||||
$this->server->monitoring()->delete();
|
||||
$this->expectExceptionMessage('Failed to fetch tags');
|
||||
SSH::fake('Active: inactive');
|
||||
Http::fake([
|
||||
@ -58,7 +59,7 @@ public function test_install_nginx(): void
|
||||
|
||||
SSH::fake('Active: active');
|
||||
|
||||
$service = app(Install::class)->install($this->server, [
|
||||
app(Install::class)->install($this->server, [
|
||||
'type' => 'webserver',
|
||||
'name' => 'nginx',
|
||||
'version' => 'latest',
|
||||
@ -71,8 +72,6 @@ public function test_install_nginx(): void
|
||||
'version' => 'latest',
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
|
||||
$this->assertNotNull($service->type_data);
|
||||
}
|
||||
|
||||
public function test_install_caddy(): void
|
||||
@ -81,7 +80,7 @@ public function test_install_caddy(): void
|
||||
|
||||
SSH::fake('Active: active');
|
||||
|
||||
$service = app(Install::class)->install($this->server, [
|
||||
app(Install::class)->install($this->server, [
|
||||
'type' => 'webserver',
|
||||
'name' => 'caddy',
|
||||
'version' => 'latest',
|
||||
@ -94,8 +93,6 @@ public function test_install_caddy(): void
|
||||
'version' => 'latest',
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
|
||||
$this->assertNotNull($service->type_data);
|
||||
}
|
||||
|
||||
public function test_install_mysql(): void
|
||||
@ -104,7 +101,7 @@ public function test_install_mysql(): void
|
||||
|
||||
SSH::fake('Active: active');
|
||||
|
||||
$service = app(Install::class)->install($this->server, [
|
||||
app(Install::class)->install($this->server, [
|
||||
'type' => 'database',
|
||||
'name' => 'mysql',
|
||||
'version' => '8.0',
|
||||
@ -117,8 +114,6 @@ public function test_install_mysql(): void
|
||||
'version' => '8.0',
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
|
||||
$this->assertNotNull($service->type_data);
|
||||
}
|
||||
|
||||
public function test_install_mysql_failed(): void
|
||||
@ -137,7 +132,7 @@ public function test_install_supervisor(): void
|
||||
|
||||
SSH::fake('Active: active');
|
||||
|
||||
$service = app(Install::class)->install($this->server, [
|
||||
app(Install::class)->install($this->server, [
|
||||
'type' => 'process_manager',
|
||||
'name' => 'supervisor',
|
||||
'version' => 'latest',
|
||||
@ -150,8 +145,6 @@ public function test_install_supervisor(): void
|
||||
'version' => 'latest',
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
|
||||
$this->assertNotNull($service->type_data);
|
||||
}
|
||||
|
||||
public function test_install_redis(): void
|
||||
@ -160,7 +153,7 @@ public function test_install_redis(): void
|
||||
|
||||
SSH::fake('Active: active');
|
||||
|
||||
$service = app(Install::class)->install($this->server, [
|
||||
app(Install::class)->install($this->server, [
|
||||
'type' => 'memory_database',
|
||||
'name' => 'redis',
|
||||
'version' => 'latest',
|
||||
@ -173,7 +166,5 @@ public function test_install_redis(): void
|
||||
'version' => 'latest',
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
|
||||
$this->assertNotNull($service->type_data);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,9 @@ public function test_uninstall_vito_agent(): void
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
Service::factory()->create([
|
||||
$this->server->monitoring()->delete();
|
||||
|
||||
$service = Service::factory()->create([
|
||||
'server_id' => $this->server->id,
|
||||
'name' => 'vito-agent',
|
||||
'type' => 'monitoring',
|
||||
@ -31,11 +33,7 @@ public function test_uninstall_vito_agent(): void
|
||||
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,
|
||||
'id' => $service->id,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,10 @@
|
||||
|
||||
class AgentTest extends TestCase
|
||||
{
|
||||
private $operatingSystems = [
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private array $operatingSystems = [
|
||||
'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko' => 'Windows',
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2' => 'OS X',
|
||||
'Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko ) Version/5.1 Mobile/9B176 Safari/7534.48.3' => 'iOS',
|
||||
@ -18,7 +21,10 @@ class AgentTest extends TestCase
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36' => 'Windows',
|
||||
];
|
||||
|
||||
private $browsers = [
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private array $browsers = [
|
||||
'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko' => 'IE',
|
||||
'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25' => 'Safari',
|
||||
'Mozilla/5.0 (Windows; U; Win 9x 4.90; SG; rv:1.9.2.4) Gecko/20101104 Netscape/9.1.0285' => 'Netscape',
|
||||
@ -36,7 +42,10 @@ class AgentTest extends TestCase
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/86.0.180 Chrome/80.0.3987.180 Safari/537.36' => 'Coc Coc',
|
||||
];
|
||||
|
||||
private $mobileDevices = [
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
private array $mobileDevices = [
|
||||
'Mozilla/5.0 (iPhone; U; ru; CPU iPhone OS 4_2_1 like Mac OS X; ru) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148a Safari/6533.18.5',
|
||||
'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25',
|
||||
'Mozilla/5.0 (Linux; U; Android 2.3.4; fr-fr; HTC Desire Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1',
|
||||
@ -45,7 +54,10 @@ class AgentTest extends TestCase
|
||||
'Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; ASUS Transformer Pad TF300T Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30',
|
||||
];
|
||||
|
||||
private $desktops = [
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
private array $desktops = [
|
||||
'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko',
|
||||
'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0',
|
||||
'Mozilla/5.0 (Windows; U; Win 9x 4.90; SG; rv:1.9.2.4) Gecko/20101104 Netscape/9.1.0285',
|
||||
@ -56,7 +68,7 @@ class AgentTest extends TestCase
|
||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2',
|
||||
];
|
||||
|
||||
public function test_operating_systems()
|
||||
public function test_operating_systems(): void
|
||||
{
|
||||
$agent = new Agent;
|
||||
|
||||
@ -66,7 +78,7 @@ public function test_operating_systems()
|
||||
}
|
||||
}
|
||||
|
||||
public function test_browsers()
|
||||
public function test_browsers(): void
|
||||
{
|
||||
$agent = new Agent;
|
||||
|
||||
@ -76,7 +88,7 @@ public function test_browsers()
|
||||
}
|
||||
}
|
||||
|
||||
public function test_desktop_devices()
|
||||
public function test_desktop_devices(): void
|
||||
{
|
||||
$agent = new Agent;
|
||||
|
||||
@ -86,7 +98,7 @@ public function test_desktop_devices()
|
||||
}
|
||||
}
|
||||
|
||||
public function test_mobile_devices()
|
||||
public function test_mobile_devices(): void
|
||||
{
|
||||
$agent = new Agent;
|
||||
|
||||
|
@ -11,7 +11,7 @@ class ServerModelTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_should_have_default_service()
|
||||
public function test_should_have_default_service(): void
|
||||
{
|
||||
$php = $this->server->defaultService('php');
|
||||
$php->update(['is_default' => false]);
|
||||
|
@ -4,10 +4,14 @@
|
||||
|
||||
use App\Facades\SSH;
|
||||
use App\SSH\Services\Database\Database;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Tests\TestCase;
|
||||
|
||||
class GetCharsetsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var array<string, array<string, string|array<string>>>
|
||||
*/
|
||||
protected static array $mysqlCharsets = [
|
||||
'armscii8' => [
|
||||
'default' => 'armscii8_general_ci',
|
||||
@ -33,8 +37,9 @@ class GetCharsetsTest extends TestCase
|
||||
];
|
||||
|
||||
/**
|
||||
* @dataProvider data
|
||||
* @param array<string, string|array<string>> $expected
|
||||
*/
|
||||
#[DataProvider('data')]
|
||||
public function test_update_charsets(string $name, string $version, string $output, array $expected): void
|
||||
{
|
||||
$database = $this->server->database();
|
||||
@ -52,7 +57,7 @@ public function test_update_charsets(string $name, string $version, string $outp
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @return array<int, array<int, mixed>>
|
||||
*/
|
||||
public static function data(): array
|
||||
{
|
||||
|
@ -4,13 +4,12 @@
|
||||
|
||||
use App\Facades\SSH;
|
||||
use App\SSH\Services\Database\Database;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Tests\TestCase;
|
||||
|
||||
class GetDatabasesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider data
|
||||
*/
|
||||
#[DataProvider('data')]
|
||||
public function test_get_databases(string $name, string $version, string $output): void
|
||||
{
|
||||
$database = $this->server->database();
|
||||
@ -24,12 +23,11 @@ public function test_get_databases(string $name, string $version, string $output
|
||||
$databaseHandler = $database->handler();
|
||||
$databases = $databaseHandler->getDatabases();
|
||||
|
||||
$this->assertIsArray($databases);
|
||||
$this->assertEquals('vito', $databases[0][0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @return array<int, array<int, mixed>>
|
||||
*/
|
||||
public static function data(): array
|
||||
{
|
||||
|
@ -4,13 +4,12 @@
|
||||
|
||||
use App\Facades\SSH;
|
||||
use App\SSH\Services\Database\Database;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Tests\TestCase;
|
||||
|
||||
class GetUsersTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider data
|
||||
*/
|
||||
#[DataProvider('data')]
|
||||
public function test_get_users(string $name, string $version, string $output): void
|
||||
{
|
||||
$database = $this->server->database();
|
||||
@ -24,12 +23,11 @@ public function test_get_users(string $name, string $version, string $output): v
|
||||
$databaseHandler = $database->handler();
|
||||
$users = $databaseHandler->getUsers();
|
||||
|
||||
$this->assertIsArray($users);
|
||||
$this->assertEquals('vito', $users[0][0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @return array<int, array<int, mixed>>
|
||||
*/
|
||||
public static function data(): array
|
||||
{
|
||||
|
@ -5,6 +5,7 @@
|
||||
use App\Models\SourceControl;
|
||||
use App\SourceControlProviders\Gitlab;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Tests\TestCase;
|
||||
|
||||
class GitlabTest extends TestCase
|
||||
@ -36,9 +37,7 @@ public function test_default_gitlab_repo_url(): void
|
||||
$this->assertSame('git@gitlab.com-TEST_KEY:test/repo.git', $gitlab->fullRepoUrl($repo, $key));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider customUrlData
|
||||
*/
|
||||
#[DataProvider('customUrlData')]
|
||||
public function test_custom_url(string $url, string $expected): void
|
||||
{
|
||||
$sourceControlModel = SourceControl::factory()
|
||||
@ -50,9 +49,7 @@ public function test_custom_url(string $url, string $expected): void
|
||||
$this->assertSame($expected, $gitlab->getApiUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider customRepoUrlData
|
||||
*/
|
||||
#[DataProvider('customRepoUrlData')]
|
||||
public function test_custom_full_repository_url(string $url, string $expected): void
|
||||
{
|
||||
$repo = 'test/repo';
|
||||
@ -67,6 +64,9 @@ public function test_custom_full_repository_url(string $url, string $expected):
|
||||
$this->assertSame($expected, $gitlab->fullRepoUrl($repo, $key));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array<int, string>>
|
||||
*/
|
||||
public static function customRepoUrlData(): array
|
||||
{
|
||||
return [
|
||||
@ -76,6 +76,9 @@ public static function customRepoUrlData(): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array<int, string>>
|
||||
*/
|
||||
public static function customUrlData(): array
|
||||
{
|
||||
return [
|
||||
|
@ -15,7 +15,7 @@ class S3Test extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_s3_connect_successful()
|
||||
public function test_s3_connect_successful(): void
|
||||
{
|
||||
$storageProvider = StorageProviderModel::factory()->create([
|
||||
'provider' => StorageProvider::S3,
|
||||
@ -59,7 +59,7 @@ public function test_s3_connect_successful()
|
||||
$this->assertTrue($s3->connect());
|
||||
}
|
||||
|
||||
public function test_s3_connect_failure()
|
||||
public function test_s3_connect_failure(): void
|
||||
{
|
||||
$storageProvider = StorageProviderModel::factory()->create([
|
||||
'provider' => StorageProvider::S3,
|
||||
|
Reference in New Issue
Block a user