Add test coverage for allocation assignment endpoint

This commit is contained in:
Dane Everitt
2020-10-31 21:57:27 -07:00
parent b2be067f38
commit d493685518
6 changed files with 204 additions and 79 deletions

View File

@@ -122,6 +122,12 @@ class NetworkAllocationController extends ClientApiController
*/
public function store(NewAllocationRequest $request, Server $server): array
{
if ($server->allocations()->count() >= $server->allocation_limit) {
throw new DisplayException(
'Cannot assign additional allocations to this server: limit has been reached.'
);
}
$allocation = $this->assignableAllocationService->handle($server);
return $this->fractal->item($allocation)

View File

@@ -46,12 +46,6 @@ class FindAssignableAllocationService
throw new AutoAllocationNotEnabledException;
}
if ($server->allocations()->count() >= $server->allocation_limit) {
throw new DisplayException(
'Cannot assign additional allocations to this server: limit has been reached.'
);
}
// Attempt to find a given available allocation for a server. If one cannot be found
// we will fall back to attempting to create a new allocation that can be used for the
// server.