Skip to content

Commit

Permalink
Add Test
Browse files Browse the repository at this point in the history
  • Loading branch information
wattnpapa committed Dec 10, 2024
1 parent 1e2822d commit 9287860
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/Commands/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Carbon\Carbon;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Storage;

it('can create a snapshot without a specific', function () {
Artisan::call('snapshot:create');
Expand Down Expand Up @@ -112,3 +113,31 @@
->fileOnDiskToFailRegex('/CREATE TABLE(?: IF NOT EXISTS){0,1} "posts"/')
->fileOnDiskToPassRegex('/CREATE TABLE(?: IF NOT EXISTS){0,1} "models"/');
});

it('passes extraOptions correctly to the command', function () {
// Set up
Storage::fake('snapshots');

// Mock or set the extraOptions you want to test
$extraOptions = ['--compress' => true, '--exclude-tables' => 'logs'];

// Execute the artisan command with extra options
Artisan::call('snapshot:create', [
'name' => 'test_snapshot',
'--disk' => 'snapshots',
'--extraOptions' => json_encode($extraOptions),
]);

// Assertions
$output = Artisan::output();
expect($output)->toContain('--compress')->toContain('true');
expect($output)->toContain('--exclude-tables')->toContain('logs');

// Verify the snapshot file was created
$snapshotFileName = 'test_snapshot.sql';
Storage::disk('snapshots')->assertExists($snapshotFileName);

// Optionally, check the snapshot's content or metadata
$snapshotContent = Storage::disk('snapshots')->get($snapshotFileName);
expect($snapshotContent)->toContain('--compress')->toContain('--exclude-tables');
});

0 comments on commit 9287860

Please sign in to comment.