2020-10-09 22:01:25 -07:00
|
|
|
<?php
|
|
|
|
|
|
2024-03-12 22:39:16 -04:00
|
|
|
namespace App\Tests\Integration\Services\Deployment;
|
2020-10-09 22:01:25 -07:00
|
|
|
|
2024-03-12 22:39:16 -04:00
|
|
|
use App\Models\Node;
|
|
|
|
|
use App\Models\Server;
|
|
|
|
|
use App\Models\Database;
|
|
|
|
|
use App\Tests\Integration\IntegrationTestCase;
|
|
|
|
|
use App\Services\Deployment\FindViableNodesService;
|
2020-10-09 22:01:25 -07:00
|
|
|
|
|
|
|
|
class FindViableNodesServiceTest extends IntegrationTestCase
|
|
|
|
|
{
|
2024-03-19 21:09:16 -04:00
|
|
|
protected function setUp(): void
|
2020-10-09 22:12:45 -07:00
|
|
|
{
|
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
|
|
Database::query()->delete();
|
|
|
|
|
Server::query()->delete();
|
|
|
|
|
Node::query()->delete();
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-19 21:12:27 -04:00
|
|
|
public function testExceptionIsThrownIfNoDiskSpaceHasBeenSet(): void
|
2020-10-09 22:01:25 -07:00
|
|
|
{
|
2023-02-23 12:30:16 -07:00
|
|
|
$this->expectException(\InvalidArgumentException::class);
|
2020-10-09 22:01:25 -07:00
|
|
|
$this->expectExceptionMessage('Disk space must be an int, got NULL');
|
|
|
|
|
|
|
|
|
|
$this->getService()->handle();
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-19 21:12:27 -04:00
|
|
|
public function testExceptionIsThrownIfNoMemoryHasBeenSet(): void
|
2020-10-09 22:01:25 -07:00
|
|
|
{
|
2023-02-23 12:30:16 -07:00
|
|
|
$this->expectException(\InvalidArgumentException::class);
|
2020-10-09 22:01:25 -07:00
|
|
|
$this->expectExceptionMessage('Memory usage must be an int, got NULL');
|
|
|
|
|
|
|
|
|
|
$this->getService()->setDisk(10)->handle();
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-14 10:59:20 -06:00
|
|
|
private function getService(): FindViableNodesService
|
2020-10-09 22:01:25 -07:00
|
|
|
{
|
|
|
|
|
return $this->app->make(FindViableNodesService::class);
|
|
|
|
|
}
|
|
|
|
|
}
|