Skip to content

Commit 5d79eb9

Browse files
Add restore test
1 parent 93d43c1 commit 5d79eb9

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/Backup/Source/Redis.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,8 @@ protected function createStatus(Target $target) : Status
226226
*/
227227
public function restore(Target $target, Plan $plan): Status
228228
{
229-
$plan->addRestoreCommand(
230-
sprintf(
231-
'cp %s %s',
232-
$target->getPathnamePlain(),
233-
$this->pathToRedisData
234-
)
235-
);
229+
$cmd = sprintf('cp %s %s', $target->getPathnamePlain(), $this->pathToRedisData);
230+
$plan->addRestoreCommand($cmd);
236231

237232
return Status::create()->uncompressedFile($target->getPathnamePlain());
238233
}

tests/phpbu/Backup/Source/RedisTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace phpbu\App\Backup\Source;
33

44
use phpbu\App\Backup\CliMockery;
5+
use phpbu\App\Backup\Restore\Plan;
56
use phpbu\App\BaseMockery;
67
use PHPUnit\Framework\TestCase;
78

@@ -166,4 +167,20 @@ public function testBackupSaveFail()
166167

167168
$redis->backup($target, $appResult);
168169
}
170+
171+
/**
172+
* Tests Redis::restore
173+
*/
174+
public function testRestore()
175+
{
176+
$plan = new Plan();
177+
$target = $this->createTargetMock('/tmp/backup.redis');
178+
$rdbPath = PHPBU_TEST_FILES . '/misc/dump.rdb';
179+
180+
$redis = new Redis();
181+
$redis->setup(['pathToRedisData' => $rdbPath, 'pathToRedisCli' => PHPBU_TEST_BIN]);
182+
$redis->restore($target, $plan);
183+
184+
$this->assertCount(1, $plan->getRestoreCommands());
185+
}
169186
}

0 commit comments

Comments
 (0)