2020-07-29 15:26:01 +00:00
|
|
|
<?php
|
|
|
|
|
|
2022-08-01 10:22:04 +00:00
|
|
|
namespace Tests\Unit\Docker;
|
2020-07-29 15:26:01 +00:00
|
|
|
|
|
|
|
|
use Appwrite\Docker\Compose;
|
|
|
|
|
use Exception;
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
|
|
class ComposeTest extends TestCase
|
|
|
|
|
{
|
2022-08-01 10:22:04 +00:00
|
|
|
protected ?Compose $object = null;
|
2020-07-29 15:26:01 +00:00
|
|
|
|
2020-09-30 21:51:38 +00:00
|
|
|
public function setUp(): void
|
2020-07-29 15:26:01 +00:00
|
|
|
{
|
2022-05-23 14:54:50 +00:00
|
|
|
$data = @file_get_contents(__DIR__ . '/../../resources/docker/docker-compose.yml');
|
2020-07-29 15:26:01 +00:00
|
|
|
|
2020-10-27 19:48:38 +00:00
|
|
|
if ($data === false) {
|
2020-07-29 15:26:01 +00:00
|
|
|
throw new Exception('Failed to read compose file');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->object = new Compose($data);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 10:22:04 +00:00
|
|
|
public function testServices(): void
|
2020-07-29 15:26:01 +00:00
|
|
|
{
|
2026-02-09 19:24:57 +00:00
|
|
|
$this->assertCount(16, $this->object->getServices());
|
2020-07-29 15:26:01 +00:00
|
|
|
$this->assertEquals('appwrite', $this->object->getService('appwrite')->getContainerName());
|
2020-07-31 06:31:29 +00:00
|
|
|
$this->assertEquals('', $this->object->getService('appwrite')->getImageVersion());
|
2026-02-06 19:16:37 +00:00
|
|
|
$this->assertEquals('3.6', $this->object->getService('traefik')->getImageVersion());
|
2020-07-31 12:50:39 +00:00
|
|
|
$this->assertEquals(['2080' => '80', '2443' => '443', '8080' => '8080'], $this->object->getService('traefik')->getPorts());
|
2020-07-29 15:26:01 +00:00
|
|
|
}
|
|
|
|
|
|
2022-08-01 10:22:04 +00:00
|
|
|
public function testNetworks(): void
|
2020-07-29 15:26:01 +00:00
|
|
|
{
|
|
|
|
|
$this->assertCount(2, $this->object->getNetworks());
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 10:22:04 +00:00
|
|
|
public function testVolumes(): void
|
2020-07-29 15:26:01 +00:00
|
|
|
{
|
2023-02-06 14:40:22 +00:00
|
|
|
$this->assertCount(7, $this->object->getVolumes());
|
2020-07-29 15:26:01 +00:00
|
|
|
$this->assertEquals('appwrite-mariadb', $this->object->getVolumes()[0]);
|
|
|
|
|
$this->assertEquals('appwrite-redis', $this->object->getVolumes()[1]);
|
|
|
|
|
$this->assertEquals('appwrite-cache', $this->object->getVolumes()[2]);
|
|
|
|
|
}
|
2020-09-30 21:51:38 +00:00
|
|
|
}
|