Fix single failing test

This commit is contained in:
Dane Everitt 2021-01-17 15:55:46 -08:00
parent a75a347d65
commit cb40b280a4
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 9 additions and 6 deletions

View file

@ -4,6 +4,7 @@ namespace Pterodactyl\Http\Controllers\Api\Remote\Servers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Pterodactyl\Models\Server;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\Eloquent\ServerRepository; use Pterodactyl\Repositories\Eloquent\ServerRepository;
@ -61,10 +62,13 @@ class ServerInstallController extends Controller
{ {
$server = $this->repository->getByUuid($uuid); $server = $this->repository->getByUuid($uuid);
$this->repository->update($server->id, [ $status = $request->input('successful') === '1' ? null : Server::STATUS_INSTALL_FAILED;
'installed' => (string) $request->input('successful') === '1' ? 1 : 2, if ($server->status === Server::STATUS_SUSPENDED) {
], true, true); $status = Server::STATUS_SUSPENDED
}
return JsonResponse::create([], Response::HTTP_NO_CONTENT); $this->repository->update($server->id, ['status' => $status], true, true);
return new JsonResponse([], Response::HTTP_NO_CONTENT);
} }
} }

View file

@ -129,7 +129,6 @@ class Server extends Model
'startup' => 'required|string', 'startup' => 'required|string',
'skip_scripts' => 'sometimes|boolean', 'skip_scripts' => 'sometimes|boolean',
'image' => 'required|string|max:191', 'image' => 'required|string|max:191',
'installed' => 'in:0,1,2',
'database_limit' => 'present|nullable|integer|min:0', 'database_limit' => 'present|nullable|integer|min:0',
'allocation_limit' => 'sometimes|nullable|integer|min:0', 'allocation_limit' => 'sometimes|nullable|integer|min:0',
'backup_limit' => 'present|nullable|integer|min:0', 'backup_limit' => 'present|nullable|integer|min:0',

View file

@ -67,7 +67,7 @@ class AccessingValidServerTest extends MiddlewareTestCase
$this->expectException(ConflictHttpException::class); $this->expectException(ConflictHttpException::class);
$this->expectExceptionMessage('Server is still completing the installation process.'); $this->expectExceptionMessage('Server is still completing the installation process.');
$model = factory(Server::class)->make(['installed' => 0]); $model = factory(Server::class)->make(['status' => Server::STATUS_INSTALLING]);
$this->request->shouldReceive('route->parameter')->with('server')->once()->andReturn('123456'); $this->request->shouldReceive('route->parameter')->with('server')->once()->andReturn('123456');
$this->request->shouldReceive('expectsJson')->withNoArgs()->once()->andReturn(true); $this->request->shouldReceive('expectsJson')->withNoArgs()->once()->andReturn(true);