2020-06-27 19:32:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Tests\Integration\Api\Client\Server;
|
|
|
|
|
|
|
|
use Pterodactyl\Models\Permission;
|
|
|
|
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
|
|
|
|
use Pterodactyl\Tests\Integration\Api\Client\ClientApiIntegrationTestCase;
|
|
|
|
|
2022-10-14 16:59:20 +00:00
|
|
|
class ResourceUtilizationControllerTest extends ClientApiIntegrationTestCase
|
2020-06-27 19:32:27 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Test that the resource utilization for a server is returned in the expected format.
|
|
|
|
*/
|
|
|
|
public function testServerResourceUtilizationIsReturned()
|
|
|
|
{
|
2022-11-29 17:53:59 +00:00
|
|
|
$service = \Mockery::mock(DaemonServerRepository::class);
|
2020-06-27 19:32:27 +00:00
|
|
|
$this->app->instance(DaemonServerRepository::class, $service);
|
|
|
|
|
|
|
|
[$user, $server] = $this->generateTestAccount([Permission::ACTION_WEBSOCKET_CONNECT]);
|
|
|
|
|
2022-11-29 17:53:59 +00:00
|
|
|
$service->expects('setServer')->with(\Mockery::on(function ($value) use ($server) {
|
2020-06-27 19:32:27 +00:00
|
|
|
return $server->uuid === $value->uuid;
|
|
|
|
}))->andReturnSelf()->getMock()->expects('getDetails')->andReturns([]);
|
|
|
|
|
2022-10-14 16:59:20 +00:00
|
|
|
$response = $this->actingAs($user)->getJson("/api/client/servers/$server->uuid/resources");
|
2020-06-27 19:32:27 +00:00
|
|
|
|
|
|
|
$response->assertOk();
|
|
|
|
$response->assertJson([
|
|
|
|
'object' => 'stats',
|
|
|
|
'attributes' => [
|
|
|
|
'current_state' => 'stopped',
|
|
|
|
'is_suspended' => false,
|
|
|
|
'resources' => [
|
|
|
|
'memory_bytes' => 0,
|
|
|
|
'cpu_absolute' => 0,
|
|
|
|
'disk_bytes' => 0,
|
|
|
|
'network_rx_bytes' => 0,
|
|
|
|
'network_tx_bytes' => 0,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|