Have the output Marker and markTidyer.

This commit is contained in:
Joao Patricio
2023-04-01 20:50:57 +01:00
parent 829a45f410
commit 940cb3c000
5 changed files with 152 additions and 18 deletions

View File

@@ -1,9 +1,9 @@
<?php
use App\Actions\RemoteProcess\TidyOutput;
use App\Models\User;
use App\Models\Server;
use Database\Seeders\DatabaseSeeder;
use Tests\Support\Output;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\RefreshDatabase;
@@ -32,9 +32,14 @@ it('starts a docker container correctly', function () {
$containerName = 'coolify_test_' . now()->format('Ymd_his');
$host = Server::where('name', 'testing-local-docker-container')->first();
remoteProcess([
"docker rm -f $(docker ps --filter='name={$coolifyNamePrefix}*' -aq)"
], $host);
// Assert there's no containers start with coolify_test_*
$activity = remoteProcess([$areThereCoolifyTestContainers], $host);
$containers = formatDockerCmdOutputToJson($activity->description);
$tidyOutput = (new TidyOutput($activity))();
$containers = formatDockerCmdOutputToJson($tidyOutput);
expect($containers)->toBeEmpty();
// start a container nginx -d --name = $containerName
@@ -43,7 +48,8 @@ it('starts a docker container correctly', function () {
// docker ps name = $container
$activity = remoteProcess([$areThereCoolifyTestContainers], $host);
$containers = formatDockerCmdOutputToJson($activity->description);
$tidyOutput = (new TidyOutput($activity))();
$containers = formatDockerCmdOutputToJson($tidyOutput);
expect($containers->where('Names', $containerName)->count())->toBe(1);
// Stop testing containers

View File

@@ -0,0 +1,36 @@
<?php
use App\Actions\RemoteProcess\RunRemoteProcess;
use App\Actions\RemoteProcess\TidyOutput;
use App\Models\Server;
use Database\Seeders\DatabaseSeeder;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
uses(DatabaseMigrations::class);
beforeEach(function () {
$this->seed(DatabaseSeeder::class);
});
it('outputs correctly', function () {
$host = Server::where('name', 'testing-local-docker-container')->first();
$activity = remoteProcess([
'pwd',
'x=1; while [ $x -le 3 ]; do sleep 0.1 && echo "Welcome $x times" $(( x++ )); done',
], $host);
preg_match(RunRemoteProcess::MARK_REGEX, $activity->description, $matchesInRawContent);
$out = (new TidyOutput($activity))();
preg_match(RunRemoteProcess::MARK_REGEX, $out, $matchesInTidyOutput);
expect($matchesInRawContent)
->not()->toBeEmpty()
->and($matchesInTidyOutput)
->toBeEmpty();
});

View File

@@ -1,5 +0,0 @@
<?php
test('that true is true', function () {
expect(true)->toBeTrue();
});