Add test coverage for allocation routes

This commit is contained in:
Dane Everitt 2020-07-10 21:17:28 -07:00
parent d040b3a242
commit a430ebb89e
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 220 additions and 2 deletions

View file

@ -15,6 +15,7 @@ use Pterodactyl\Models\Subuser;
use Pterodactyl\Models\Location;
use Pterodactyl\Models\Schedule;
use Illuminate\Support\Collection;
use Pterodactyl\Models\Allocation;
use Pterodactyl\Tests\Integration\IntegrationTestCase;
use Pterodactyl\Transformers\Api\Client\BaseClientTransformer;
@ -53,7 +54,7 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
*/
protected function link($model, $append = null): string
{
Assert::isInstanceOfAny($model, [Server::class, Schedule::class, Task::class]);
Assert::isInstanceOfAny($model, [Server::class, Schedule::class, Task::class, Allocation::class]);
$link = '';
switch (get_class($model)) {
@ -66,6 +67,9 @@ abstract class ClientApiIntegrationTestCase extends IntegrationTestCase
case Task::class:
$link = "/api/client/servers/{$model->schedule->server->uuid}/schedules/{$model->schedule->id}/tasks/{$model->id}";
break;
case Allocation::class:
$link = "/api/client/servers/{$model->server->uuid}/network/allocations/{$model->id}";
break;
}
return $link . ($append ? '/' . ltrim($append, '/') : '');