Adds Pest tests. Starts GH Action.

This commit is contained in:
Joao Patricio
2023-03-20 21:17:28 +00:00
parent 9a7a992495
commit d7c7494007
9 changed files with 967 additions and 36 deletions

View File

@@ -0,0 +1,32 @@
<?php
use Tests\Support\Output;
it('starts a docker container correctly', function () {
$coolifyNamePrefix = 'coolify_test_';
$format = '{"ID":"{{ .ID }}", "Image": "{{ .Image }}", "Names":"{{ .Names }}"}';
$areThereCoolifyTestContainers = "docker ps --filter=\"name={$coolifyNamePrefix}*\" --format '{$format}' ";
// Generate a known name
$containerName = 'coolify_test_' . now()->format('Ymd_his');
$host = 'testing-host';
// Assert there's no containers start with coolify_test_*
$processResult = coolifyProcess($areThereCoolifyTestContainers, $host);
$containers = Output::containerList($processResult->output());
expect($containers)->toBeEmpty();
// start a container nginx -d --name = $containerName
$processResult = coolifyProcess("docker run -d --name {$containerName} nginx", $host);
expect($processResult->successful())->toBeTrue();
// docker ps name = $container
$processResult = coolifyProcess($areThereCoolifyTestContainers, $host);
$containers = Output::containerList($processResult->output());
expect($containers->where('Names', $containerName)->count())->toBe(1);
// Stop testing containers
$processResult = coolifyProcess("docker stop $(docker ps --filter='name={$coolifyNamePrefix}*' -q)", $host);
expect($processResult->successful())->toBeTrue();
});

View File

@@ -1,19 +0,0 @@
<?php
namespace Tests\Feature;
// use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*/
public function test_the_application_returns_a_successful_response(): void
{
$response = $this->get('/');
$response->assertStatus(200);
}
}