mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-14 08:18:08 +00:00
test(factories): add missing model factories for app test suite
Enable `HasFactory` on `Environment`, `Project`, `ScheduledTask`, and `StandaloneDocker`, and add dedicated factories for related models to stabilize feature/unit tests. Also bump `visus/cuid2` to `^6.0` and refresh `composer.lock` with the resulting dependency updates.
This commit is contained in:
1 parent
e1a7c64f37
commit
7ae76ebc79
20 files changed
+752
-635
No files matched your search
@@ -2,42 +2,23 @@
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Models\ApplicationSetting;
|
||||
use App\Models\Environment;
|
||||
use App\Models\Project;
|
||||
use App\Models\Server;
|
||||
use App\Models\Team;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('Application Rollback', function () {
|
||||
beforeEach(function () {
|
||||
$team = Team::factory()->create();
|
||||
$project = Project::create([
|
||||
'team_id' => $team->id,
|
||||
'name' => 'Test Project',
|
||||
'uuid' => (string) str()->uuid(),
|
||||
]);
|
||||
$environment = Environment::create([
|
||||
'project_id' => $project->id,
|
||||
'name' => 'rollback-test-env',
|
||||
'uuid' => (string) str()->uuid(),
|
||||
]);
|
||||
$server = Server::factory()->create(['team_id' => $team->id]);
|
||||
|
||||
$this->application = Application::factory()->create([
|
||||
'environment_id' => $environment->id,
|
||||
'destination_id' => $server->id,
|
||||
$this->application = new Application;
|
||||
$this->application->forceFill([
|
||||
'uuid' => 'test-app-uuid',
|
||||
'git_commit_sha' => 'HEAD',
|
||||
]);
|
||||
|
||||
$settings = new ApplicationSetting;
|
||||
$settings->is_git_shallow_clone_enabled = false;
|
||||
$settings->is_git_submodules_enabled = false;
|
||||
$settings->is_git_lfs_enabled = false;
|
||||
$this->application->setRelation('settings', $settings);
|
||||
});
|
||||
|
||||
test('setGitImportSettings uses passed commit instead of application git_commit_sha', function () {
|
||||
ApplicationSetting::create([
|
||||
'application_id' => $this->application->id,
|
||||
'is_git_shallow_clone_enabled' => false,
|
||||
]);
|
||||
|
||||
$rollbackCommit = 'abc123def456abc123def456abc123def456abc1';
|
||||
|
||||
$result = $this->application->setGitImportSettings(
|
||||
@@ -51,10 +32,7 @@ describe('Application Rollback', function () {
|
||||
});
|
||||
|
||||
test('setGitImportSettings with shallow clone fetches specific commit', function () {
|
||||
ApplicationSetting::create([
|
||||
'application_id' => $this->application->id,
|
||||
'is_git_shallow_clone_enabled' => true,
|
||||
]);
|
||||
$this->application->settings->is_git_shallow_clone_enabled = true;
|
||||
|
||||
$rollbackCommit = 'abc123def456abc123def456abc123def456abc1';
|
||||
|
||||
@@ -71,12 +49,7 @@ describe('Application Rollback', function () {
|
||||
});
|
||||
|
||||
test('setGitImportSettings falls back to git_commit_sha when no commit passed', function () {
|
||||
$this->application->update(['git_commit_sha' => 'def789abc012def789abc012def789abc012def7']);
|
||||
|
||||
ApplicationSetting::create([
|
||||
'application_id' => $this->application->id,
|
||||
'is_git_shallow_clone_enabled' => false,
|
||||
]);
|
||||
$this->application->git_commit_sha = 'def789abc012def789abc012def789abc012def7';
|
||||
|
||||
$result = $this->application->setGitImportSettings(
|
||||
deployment_uuid: 'test-uuid',
|
||||
@@ -88,11 +61,6 @@ describe('Application Rollback', function () {
|
||||
});
|
||||
|
||||
test('setGitImportSettings escapes shell metacharacters in commit parameter', function () {
|
||||
ApplicationSetting::create([
|
||||
'application_id' => $this->application->id,
|
||||
'is_git_shallow_clone_enabled' => false,
|
||||
]);
|
||||
|
||||
$maliciousCommit = 'abc123; rm -rf /';
|
||||
|
||||
$result = $this->application->setGitImportSettings(
|
||||
@@ -109,11 +77,6 @@ describe('Application Rollback', function () {
|
||||
});
|
||||
|
||||
test('setGitImportSettings does not append checkout when commit is HEAD', function () {
|
||||
ApplicationSetting::create([
|
||||
'application_id' => $this->application->id,
|
||||
'is_git_shallow_clone_enabled' => false,
|
||||
]);
|
||||
|
||||
$result = $this->application->setGitImportSettings(
|
||||
deployment_uuid: 'test-uuid',
|
||||
git_clone_command: 'git clone',
|
||||
|
||||
Reference in new issue
Block a user