Refactor how repositories for the daemon work.

This commit is contained in:
Dane Everitt 2018-01-05 18:27:47 -06:00
parent 5f9fe4a69b
commit d2afc29a80
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
58 changed files with 388 additions and 997 deletions

View file

@ -4,6 +4,7 @@ namespace Tests\Unit\Services\Allocations;
use Mockery as m;
use Tests\TestCase;
use GuzzleHttp\Psr7\Response;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\Allocation;
use Tests\Traits\MocksRequestException;
@ -71,10 +72,9 @@ class SetDefaultAllocationServiceTest extends TestCase
$this->serverRepository->shouldReceive('withoutFreshModel')->withNoArgs()->once()->andReturnSelf();
$this->serverRepository->shouldReceive('update')->with($model->id, [
'allocation_id' => $allocations->first()->id,
])->once()->andReturnNull();
])->once()->andReturn(new Response);
$this->daemonRepository->shouldReceive('setAccessServer')->with($model->uuid)->once()->andReturnSelf();
$this->daemonRepository->shouldReceive('setNode')->with($model->node_id)->once()->andReturnSelf();
$this->daemonRepository->shouldReceive('setServer')->with($model)->once()->andReturnSelf();
$this->daemonRepository->shouldReceive('update')->with([
'build' => [
'default' => [
@ -85,7 +85,7 @@ class SetDefaultAllocationServiceTest extends TestCase
return $item->pluck('port');
})->toArray(),
],
])->once()->andReturnNull();
])->once()->andReturn(new Response);
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
$response = $this->getService()->handle($useModel ? $model : 1234, $allocations->first()->id);
@ -121,9 +121,9 @@ class SetDefaultAllocationServiceTest extends TestCase
$this->serverRepository->shouldReceive('withoutFreshModel')->withNoArgs()->once()->andReturnSelf();
$this->serverRepository->shouldReceive('update')->with($model->id, [
'allocation_id' => $allocation->id,
])->once()->andReturnNull();
])->once()->andReturn(new Response);
$this->daemonRepository->shouldReceive('setAccessServer->setNode->update')->once()->andThrow($this->getExceptionMock());
$this->daemonRepository->shouldReceive('setServer->update')->once()->andThrow($this->getExceptionMock());
$this->connection->shouldReceive('rollBack')->withNoArgs()->once()->andReturnNull();
try {