wip
This commit is contained in:
@@ -2,13 +2,28 @@
|
||||
|
||||
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;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
uses(DatabaseMigrations::class);
|
||||
|
||||
beforeEach(function () {
|
||||
$this->seed(DatabaseSeeder::class);
|
||||
});
|
||||
|
||||
it('starts a docker container correctly', function () {
|
||||
|
||||
test()->actingAs(User::factory()->create());
|
||||
test()->actingAs(User::factory([
|
||||
'uuid' => Str::uuid(),
|
||||
'email' => Str::uuid().'@example.com',
|
||||
])->create());
|
||||
|
||||
$coolifyNamePrefix = 'coolify_test_';
|
||||
|
||||
|
||||
$format = '{"ID":"{{ .ID }}", "Image": "{{ .Image }}", "Names":"{{ .Names }}"}';
|
||||
$areThereCoolifyTestContainers = "docker ps --filter=\"name={$coolifyNamePrefix}*\" --format '{$format}' ";
|
||||
|
||||
@@ -16,6 +31,14 @@ it('starts a docker container correctly', function () {
|
||||
$containerName = 'coolify_test_' . now()->format('Ymd_his');
|
||||
$host = Server::where('name', 'testing-local-docker-container')->first();
|
||||
|
||||
// Stop testing containers
|
||||
$activity = remoteProcess([
|
||||
"docker stop $(docker ps --filter='name={$coolifyNamePrefix}*' -aq)",
|
||||
"docker rm $(docker ps --filter='name={$coolifyNamePrefix}*' -aq)",
|
||||
], $host);
|
||||
ray($activity->description);
|
||||
expect($activity->getExtraProperty('exitCode'))->toBe(0);
|
||||
|
||||
// Assert there's no containers start with coolify_test_*
|
||||
$activity = remoteProcess([$areThereCoolifyTestContainers], $host);
|
||||
$containers = Output::containerList($activity->getExtraProperty('stdout'));
|
||||
@@ -31,6 +54,9 @@ it('starts a docker container correctly', function () {
|
||||
expect($containers->where('Names', $containerName)->count())->toBe(1);
|
||||
|
||||
// Stop testing containers
|
||||
$activity = remoteProcess(["docker stop $(docker ps --filter='name={$coolifyNamePrefix}*' -q)"], $host);
|
||||
$activity = remoteProcess([
|
||||
"docker stop $(docker ps --filter='name={$coolifyNamePrefix}*' -aq)",
|
||||
"docker rm $(docker ps --filter='name={$coolifyNamePrefix}*' -aq)",
|
||||
], $host);
|
||||
expect($activity->getExtraProperty('exitCode'))->toBe(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user