Return tests to passing state
This commit is contained in:
parent
e96ead4c4d
commit
fde0660e6c
3 changed files with 17 additions and 45 deletions
|
@ -26,8 +26,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->daemonServerRepository = Mockery::mock(DaemonServerRepository::class);
|
$this->daemonServerRepository = $this->mock(DaemonServerRepository::class);
|
||||||
$this->swap(DaemonServerRepository::class, $this->daemonServerRepository);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,7 +49,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||||
$allocations[2]->update(['server_id' => $server2->id]);
|
$allocations[2]->update(['server_id' => $server2->id]);
|
||||||
$allocations[3]->update(['server_id' => $server2->id]);
|
$allocations[3]->update(['server_id' => $server2->id]);
|
||||||
|
|
||||||
$this->daemonServerRepository->expects('setServer->update')->andReturnUndefined();
|
$this->daemonServerRepository->expects('setServer->sync')->andReturnUndefined();
|
||||||
|
|
||||||
$response = $this->getService()->handle($server, [
|
$response = $this->getService()->handle($server, [
|
||||||
// Attempt to add one new allocation, and an allocation assigned to another server. The
|
// Attempt to add one new allocation, and an allocation assigned to another server. The
|
||||||
|
@ -113,20 +112,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||||
return $s->id === $server->id;
|
return $s->id === $server->id;
|
||||||
}))->andReturnSelf();
|
}))->andReturnSelf();
|
||||||
|
|
||||||
$this->daemonServerRepository->expects('update')->with(Mockery::on(function ($data) {
|
$this->daemonServerRepository->expects('sync')->withNoArgs()->andReturnUndefined();
|
||||||
$this->assertEquals([
|
|
||||||
'build' => [
|
|
||||||
'memory_limit' => 256,
|
|
||||||
'swap' => 128,
|
|
||||||
'io_weight' => 600,
|
|
||||||
'cpu_limit' => 150,
|
|
||||||
'threads' => '1,2',
|
|
||||||
'disk_space' => 1024,
|
|
||||||
],
|
|
||||||
], $data);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}))->andReturnUndefined();
|
|
||||||
|
|
||||||
$response = $this->getService()->handle($server, [
|
$response = $this->getService()->handle($server, [
|
||||||
'oom_disabled' => false,
|
'oom_disabled' => false,
|
||||||
|
@ -162,7 +148,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||||
{
|
{
|
||||||
$server = $this->createServerModel();
|
$server = $this->createServerModel();
|
||||||
|
|
||||||
$this->daemonServerRepository->expects('setServer->update')->andThrows(
|
$this->daemonServerRepository->expects('setServer->sync')->andThrows(
|
||||||
new DaemonConnectionException(
|
new DaemonConnectionException(
|
||||||
new RequestException('Bad request', new Request('GET', '/test'), new Response())
|
new RequestException('Bad request', new Request('GET', '/test'), new Response())
|
||||||
)
|
)
|
||||||
|
@ -186,7 +172,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||||
/** @var \Pterodactyl\Models\Allocation $allocation */
|
/** @var \Pterodactyl\Models\Allocation $allocation */
|
||||||
$allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]);
|
$allocation = Allocation::factory()->create(['node_id' => $server->node_id, 'server_id' => $server->id]);
|
||||||
|
|
||||||
$this->daemonServerRepository->expects('setServer->update')->andReturnUndefined();
|
$this->daemonServerRepository->expects('setServer->sync')->andReturnUndefined();
|
||||||
|
|
||||||
$this->getService()->handle($server, [
|
$this->getService()->handle($server, [
|
||||||
'remove_allocations' => [$allocation->id],
|
'remove_allocations' => [$allocation->id],
|
||||||
|
@ -209,7 +195,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||||
/** @var \Pterodactyl\Models\Allocation $allocation */
|
/** @var \Pterodactyl\Models\Allocation $allocation */
|
||||||
$allocation = Allocation::factory()->create(['node_id' => $server->node_id]);
|
$allocation = Allocation::factory()->create(['node_id' => $server->node_id]);
|
||||||
|
|
||||||
$this->daemonServerRepository->expects('setServer->update')->andReturnUndefined();
|
$this->daemonServerRepository->expects('setServer->sync')->andReturnUndefined();
|
||||||
|
|
||||||
$this->getService()->handle($server, [
|
$this->getService()->handle($server, [
|
||||||
'add_allocations' => [$allocation->id],
|
'add_allocations' => [$allocation->id],
|
||||||
|
@ -230,7 +216,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||||
/** @var \Pterodactyl\Models\Allocation $allocation2 */
|
/** @var \Pterodactyl\Models\Allocation $allocation2 */
|
||||||
$allocation2 = Allocation::factory()->create(['node_id' => $server->node_id]);
|
$allocation2 = Allocation::factory()->create(['node_id' => $server->node_id]);
|
||||||
|
|
||||||
$this->daemonServerRepository->expects('setServer->update')->andReturnUndefined();
|
$this->daemonServerRepository->expects('setServer->sync')->andReturnUndefined();
|
||||||
|
|
||||||
$this->getService()->handle($server, [
|
$this->getService()->handle($server, [
|
||||||
'add_allocations' => [$allocation2->id, $allocation2->id],
|
'add_allocations' => [$allocation2->id, $allocation2->id],
|
||||||
|
@ -253,7 +239,7 @@ class BuildModificationServiceTest extends IntegrationTestCase
|
||||||
/** @var \Pterodactyl\Models\Allocation $allocation */
|
/** @var \Pterodactyl\Models\Allocation $allocation */
|
||||||
$allocation = Allocation::factory()->create(['node_id' => $server->node_id]);
|
$allocation = Allocation::factory()->create(['node_id' => $server->node_id]);
|
||||||
|
|
||||||
$this->daemonServerRepository->expects('setServer->update')->andThrows(new DisplayException('Test'));
|
$this->daemonServerRepository->expects('setServer->sync')->andThrows(new DisplayException('Test'));
|
||||||
|
|
||||||
$this->expectException(DisplayException::class);
|
$this->expectException(DisplayException::class);
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,6 @@ class ServerCreationServiceTest extends IntegrationTestCase
|
||||||
$allocations[0]->port,
|
$allocations[0]->port,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/** @noinspection PhpParamsInspection */
|
|
||||||
$egg = $this->cloneEggAndVariables(Egg::query()->findOrFail(1));
|
$egg = $this->cloneEggAndVariables(Egg::query()->findOrFail(1));
|
||||||
// We want to make sure that the validator service runs as an admin, and not as a regular
|
// We want to make sure that the validator service runs as an admin, and not as a regular
|
||||||
// user when saving variables.
|
// user when saving variables.
|
||||||
|
@ -94,19 +93,10 @@ class ServerCreationServiceTest extends IntegrationTestCase
|
||||||
'BUNGEE_VERSION' => '123',
|
'BUNGEE_VERSION' => '123',
|
||||||
'SERVER_JARFILE' => 'server2.jar',
|
'SERVER_JARFILE' => 'server2.jar',
|
||||||
],
|
],
|
||||||
|
'start_on_completion' => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->daemonServerRepository->expects('setServer')->andReturnSelf();
|
$this->daemonServerRepository->expects('setServer->create')->with(true)->andReturnUndefined();
|
||||||
$this->daemonServerRepository->expects('create')->with(Mockery::on(function ($value) {
|
|
||||||
$this->assertIsArray($value);
|
|
||||||
// Just check for some keys to make sure we're getting the expected configuration
|
|
||||||
// structure back. Other tests exist to confirm it is the correct structure.
|
|
||||||
$this->assertArrayHasKey('uuid', $value);
|
|
||||||
$this->assertArrayHasKey('environment', $value);
|
|
||||||
$this->assertArrayHasKey('invocation', $value);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}))->andReturnUndefined();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->getService()->handle(array_merge($data, [
|
$this->getService()->handle(array_merge($data, [
|
||||||
|
@ -115,7 +105,8 @@ class ServerCreationServiceTest extends IntegrationTestCase
|
||||||
'SERVER_JARFILE' => 'server2.jar',
|
'SERVER_JARFILE' => 'server2.jar',
|
||||||
],
|
],
|
||||||
]), $deployment);
|
]), $deployment);
|
||||||
$this->assertTrue(false, 'This statement should not be reached.');
|
|
||||||
|
$this->fail('This execution pathway should not be reached.');
|
||||||
} catch (ValidationException $exception) {
|
} catch (ValidationException $exception) {
|
||||||
$this->assertCount(1, $exception->errors());
|
$this->assertCount(1, $exception->errors());
|
||||||
$this->assertArrayHasKey('environment.BUNGEE_VERSION', $exception->errors());
|
$this->assertArrayHasKey('environment.BUNGEE_VERSION', $exception->errors());
|
||||||
|
@ -133,11 +124,11 @@ class ServerCreationServiceTest extends IntegrationTestCase
|
||||||
$this->assertSame('server2.jar', $response->variables[1]->server_value);
|
$this->assertSame('server2.jar', $response->variables[1]->server_value);
|
||||||
|
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
if (in_array($key, ['allocation_additional', 'environment'])) {
|
if (in_array($key, ['allocation_additional', 'environment', 'start_on_completion'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertSame($value, $response->{$key});
|
$this->assertSame($value, $response->{$key}, "Failed asserting equality of '$key' in server response. Got: [{$response->{$key}}] Expected: [$value]");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertCount(2, $response->allocations);
|
$this->assertCount(2, $response->allocations);
|
||||||
|
|
|
@ -29,20 +29,15 @@ class SuspensionServiceTest extends IntegrationTestCase
|
||||||
{
|
{
|
||||||
$server = $this->createServerModel();
|
$server = $this->createServerModel();
|
||||||
|
|
||||||
$this->repository->expects('setServer')->twice()->andReturnSelf();
|
$this->repository->expects('setServer->sync')->twice()->andReturnSelf();
|
||||||
$this->repository->expects('suspend')->with(false)->andReturnUndefined();
|
|
||||||
|
|
||||||
$this->getService()->toggle($server, SuspensionService::ACTION_SUSPEND);
|
$this->getService()->toggle($server, SuspensionService::ACTION_SUSPEND);
|
||||||
|
|
||||||
$server->refresh();
|
$this->assertTrue($server->refresh()->isSuspended());
|
||||||
$this->assertTrue($server->isSuspended());
|
|
||||||
|
|
||||||
$this->repository->expects('suspend')->with(true)->andReturnUndefined();
|
|
||||||
|
|
||||||
$this->getService()->toggle($server, SuspensionService::ACTION_UNSUSPEND);
|
$this->getService()->toggle($server, SuspensionService::ACTION_UNSUSPEND);
|
||||||
|
|
||||||
$server->refresh();
|
$this->assertFalse($server->refresh()->isSuspended());
|
||||||
$this->assertFalse($server->isSuspended());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNoActionIsTakenIfSuspensionStatusIsUnchanged()
|
public function testNoActionIsTakenIfSuspensionStatusIsUnchanged()
|
||||||
|
|
Loading…
Reference in a new issue