lasthourcloud/tests/Feature/RemoteProcessTest.php

33 lines
827 B
PHP
Raw Normal View History

2023-04-01 19:50:57 +00:00
<?php
2023-05-03 05:15:45 +00:00
use App\Actions\CoolifyTask\RunRemoteProcess;
2023-04-01 19:50:57 +00:00
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();
2023-05-24 13:25:08 +00:00
$activity = remote_process([
2023-04-01 19:50:57 +00:00
'pwd',
'x=1; while [ $x -le 3 ]; do sleep 0.1 && echo "Welcome $x times" $(( x++ )); done',
], $host);
2023-04-07 14:58:45 +00:00
$tidyOutput = RunRemoteProcess::decodeOutput($activity);
2023-04-01 19:50:57 +00:00
2023-04-07 14:58:45 +00:00
expect($tidyOutput)
->toContain('Welcome 1 times')
->toContain('Welcome 3 times')
->not()->toBeJson();
2023-04-01 19:50:57 +00:00
});