Skip to content

Commit cadc4fb

Browse files
authored
Merge pull request #67 from Vusys/compress
Fix compression option from config not being respected
2 parents 9c6d05b + 39b77ba commit cadc4fb

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/Commands/Create.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public function handle()
2323

2424
$snapshotName = $this->argument('name') ?: Carbon::now()->format('Y-m-d_H-i-s');
2525

26-
$compress = $this->option('compress', null);
26+
$compress = $this->option('compress') || config('db-snapshots.compress', false);
2727

2828
$snapshot = app(SnapshotFactory::class)->create(
2929
$snapshotName,
3030
config('db-snapshots.disk'),
3131
$connectionName,
32-
($compress !== null) ? $compress : (bool) config('db-snapshots.compress', false)
32+
$compress
3333
);
3434

3535
$size = Format::humanReadableSize($snapshot->size());

tests/Commands/CreateTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function it_can_create_a_snapshot_with_specific_name()
2727
}
2828

2929
/** @test */
30-
public function it_can_create_a_compressed_snapshot()
30+
public function it_can_create_a_compressed_snapshot_from_cli_param()
3131
{
3232
Artisan::call('snapshot:create', ['--compress' => true]);
3333

@@ -37,4 +37,18 @@ public function it_can_create_a_compressed_snapshot()
3737

3838
$this->assertNotEmpty(gzdecode($this->disk->get($fileName)));
3939
}
40+
41+
/** @test */
42+
public function it_can_create_a_compressed_snapshot_from_config()
43+
{
44+
$this->app['config']->set('db-snapshots.compress', true);
45+
46+
Artisan::call('snapshot:create');
47+
48+
$fileName = Carbon::now()->format('Y-m-d_H-i-s').'.sql.gz';
49+
50+
$this->disk->assertExists($fileName);
51+
52+
$this->assertNotEmpty(gzdecode($this->disk->get($fileName)));
53+
}
4054
}

0 commit comments

Comments
 (0)