increase test coverage (#117)

70% test coverage
remove socialite
This commit is contained in:
Saeed Vaziry
2024-03-15 22:23:45 +01:00
committed by GitHub
parent 4f12de9586
commit a406491160
62 changed files with 1102 additions and 639 deletions

View File

@ -2,6 +2,7 @@
namespace Tests\Feature;
use App\Actions\Database\RunBackup;
use App\Enums\BackupFileStatus;
use App\Enums\BackupStatus;
use App\Facades\SSH;
@ -9,6 +10,7 @@
use App\Models\Database;
use App\Models\StorageProvider;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
@ -48,6 +50,34 @@ public function test_create_backup(): void
]);
}
public function test_create_custom_interval_backup(): void
{
Bus::fake();
$this->actingAs($this->user);
$database = Database::factory()->create([
'server_id' => $this->server,
]);
$storage = StorageProvider::factory()->create([
'user_id' => $this->user->id,
'provider' => \App\Enums\StorageProvider::DROPBOX,
]);
$this->post(route('servers.databases.backups.store', $this->server), [
'backup_database' => $database->id,
'backup_storage' => $storage->id,
'backup_interval' => 'custom',
'backup_custom' => '* * * * *',
'backup_keep' => '10',
])->assertSessionDoesntHaveErrors();
$this->assertDatabaseHas('backups', [
'status' => BackupStatus::RUNNING,
]);
}
public function test_see_backups_list(): void
{
$this->actingAs($this->user);
@ -97,4 +127,43 @@ public function test_delete_backup(): void
'id' => $backup->id,
]);
}
public function test_restore_backup(): void
{
Http::fake();
SSH::fake();
$this->actingAs($this->user);
$database = Database::factory()->create([
'server_id' => $this->server,
]);
$storage = StorageProvider::factory()->create([
'user_id' => $this->user->id,
'provider' => \App\Enums\StorageProvider::DROPBOX,
]);
$backup = Backup::factory()->create([
'server_id' => $this->server->id,
'database_id' => $database->id,
'storage_id' => $storage->id,
]);
$backupFile = app(RunBackup::class)->run($backup);
$this->post(route('servers.databases.backups.files.restore', [
'server' => $this->server,
'backup' => $backup,
'backupFile' => $backupFile,
]), [
'database' => $database->id,
])
->assertSessionDoesntHaveErrors();
$this->assertDatabaseHas('backup_files', [
'id' => $backupFile->id,
'status' => BackupFileStatus::RESTORED,
]);
}
}