mirror of
https://github.com/tiennm99/coolify.git
synced 2026-06-23 19:35:31 +00:00
refactor(models): extract defaultStandaloneDockerAttributes method on Server
Extract duplicated inline StandaloneDocker attribute arrays in the Server boot lifecycle into a dedicated method, eliminating repetition between the root-server (id=0) and normal-server paths. Also harden the shared_environment_variables migration by wrapping DDL statements in DB::transaction() and using DROP CONSTRAINT IF EXISTS to make the migration safely re-runnable. Add unit test covering the extracted method to verify uuid is always present in bootstrap attributes.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Server;
|
||||
|
||||
it('includes a uuid in standalone docker bootstrap attributes for the root server path', function () {
|
||||
$server = new Server;
|
||||
$server->id = 0;
|
||||
|
||||
$attributes = $server->defaultStandaloneDockerAttributes(id: 0);
|
||||
|
||||
expect($attributes)
|
||||
->toMatchArray([
|
||||
'id' => 0,
|
||||
'name' => 'coolify',
|
||||
'network' => 'coolify',
|
||||
'server_id' => 0,
|
||||
])
|
||||
->and($attributes['uuid'])->toBeString()
|
||||
->and($attributes['uuid'])->not->toBe('');
|
||||
});
|
||||
Reference in New Issue
Block a user