File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
tests/Integration/Api/Client/Server Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Pterodactyl \Tests \Integration \Api \Client \Server ;
4+
5+ use Mockery ;
6+ use Pterodactyl \Models \Permission ;
7+ use Pterodactyl \Repositories \Wings \DaemonServerRepository ;
8+ use Pterodactyl \Tests \Integration \Api \Client \ClientApiIntegrationTestCase ;
9+
10+ class ResourceUtilitizationControllerTest extends ClientApiIntegrationTestCase
11+ {
12+ /**
13+ * Test that the resource utilization for a server is returned in the expected format.
14+ */
15+ public function testServerResourceUtilizationIsReturned ()
16+ {
17+ $ service = Mockery::mock (DaemonServerRepository::class);
18+ $ this ->app ->instance (DaemonServerRepository::class, $ service );
19+
20+ [$ user , $ server ] = $ this ->generateTestAccount ([Permission::ACTION_WEBSOCKET_CONNECT ]);
21+
22+ $ service ->expects ('setServer ' )->with (Mockery::on (function ($ value ) use ($ server ) {
23+ return $ server ->uuid === $ value ->uuid ;
24+ }))->andReturnSelf ()->getMock ()->expects ('getDetails ' )->andReturns ([]);
25+
26+ $ response = $ this ->actingAs ($ user )->getJson ("/api/client/servers/ {$ server ->uuid }/resources " );
27+
28+ $ response ->assertOk ();
29+ $ response ->assertJson ([
30+ 'object ' => 'stats ' ,
31+ 'attributes ' => [
32+ 'current_state ' => 'stopped ' ,
33+ 'is_suspended ' => false ,
34+ 'resources ' => [
35+ 'memory_bytes ' => 0 ,
36+ 'cpu_absolute ' => 0 ,
37+ 'disk_bytes ' => 0 ,
38+ 'network_rx_bytes ' => 0 ,
39+ 'network_tx_bytes ' => 0 ,
40+ ],
41+ ],
42+ ]);
43+ }
44+ }
You can’t perform that action at this time.
0 commit comments