appwrite/tests/unit/Docker/ComposeTest.php

60 lines
1.7 KiB
PHP
Raw Normal View History

2020-07-29 15:26:01 +00:00
<?php
namespace Appwrite\Tests;
use Appwrite\Docker\Compose;
use Exception;
use PHPUnit\Framework\TestCase;
class ComposeTest extends TestCase
{
/**
* @var Compose
*/
protected $object = null;
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);
}
2020-09-30 21:51:38 +00:00
public function tearDown(): void
2020-07-29 15:26:01 +00:00
{
}
public function testVersion()
{
$this->assertEquals('3', $this->object->getVersion());
}
public function testServices()
{
2022-01-31 23:44:55 +00:00
$this->assertCount(17, $this->object->getServices());
2020-07-29 15:26:01 +00:00
$this->assertEquals('appwrite-telegraf', $this->object->getService('telegraf')->getContainerName());
$this->assertEquals('appwrite', $this->object->getService('appwrite')->getContainerName());
2020-07-31 06:31:29 +00:00
$this->assertEquals('', $this->object->getService('appwrite')->getImageVersion());
$this->assertEquals('2.2', $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
}
public function testNetworks()
{
$this->assertCount(2, $this->object->getNetworks());
}
public function testVolumes()
{
$this->assertCount(9, $this->object->getVolumes());
$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
}