mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-23 08:45:04 +01:00
Add tests for deploy:release
This commit is contained in:
parent
ef3fc18c92
commit
67063c3c24
@ -4,7 +4,7 @@
|
||||
[v6.0.4...master](https://github.com/deployphp/deployer/compare/v6.0.4...master)
|
||||
|
||||
### Fixed
|
||||
- Fixed `previous_release` var
|
||||
- Fixed `previous_release` param when `release_name` was overrided [#1455]
|
||||
|
||||
## v6.0.4
|
||||
[v6.0.3...v6.0.4](https://github.com/deployphp/deployer/compare/v6.0.3...v6.0.4)
|
||||
@ -331,6 +331,8 @@
|
||||
- Fixed typo3 recipe
|
||||
- Fixed remove of shared dir on first deploy
|
||||
|
||||
|
||||
[#1455]: https://github.com/deployphp/deployer/pull/1455
|
||||
[#1452]: https://github.com/deployphp/deployer/pull/1452
|
||||
[#1426]: https://github.com/deployphp/deployer/pull/1426
|
||||
[#1413]: https://github.com/deployphp/deployer/pull/1413
|
||||
|
@ -106,6 +106,10 @@ task('deploy:release', function () {
|
||||
run('rm release'); // Delete symlink
|
||||
}
|
||||
|
||||
// We need to get releases_list at same point as release_name,
|
||||
// as standard release_name's implementation depends on it and,
|
||||
// if user overrides it, we need to get releases_list manually.
|
||||
$releasesList = get('releases_list');
|
||||
$releaseName = get('release_name');
|
||||
|
||||
// Fix collisions
|
||||
@ -116,7 +120,6 @@ task('deploy:release', function () {
|
||||
}
|
||||
|
||||
$releasePath = parse("{{deploy_path}}/releases/{{release_name}}");
|
||||
$releasesList = get('releases_list');
|
||||
|
||||
// Metainfo.
|
||||
$date = run('date +"%Y%m%d%H%M%S"');
|
||||
|
28
test/fixture/recipe/release.php
Normal file
28
test/fixture/recipe/release.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/* (c) Anton Medvedev <anton@medv.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Deployer;
|
||||
|
||||
require 'recipe/common.php';
|
||||
|
||||
localhost()
|
||||
->set('deploy_path', __DIR__ . '/tmp/localhost');
|
||||
|
||||
desc('Deploy ');
|
||||
task('deploy', [
|
||||
'deploy:prepare',
|
||||
'deploy:release',
|
||||
'deploy:symlink',
|
||||
'result',
|
||||
]);
|
||||
|
||||
task('result', function () {
|
||||
writeln('release_path {{release_path}}');
|
||||
if (has('previous_release')) {
|
||||
writeln('previous_release {{previous_release}}');
|
||||
}
|
||||
});
|
65
test/recipe/ReleaseTest.php
Normal file
65
test/recipe/ReleaseTest.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/* (c) Anton Medvedev <anton@medv.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Deployer;
|
||||
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ReleaseTest extends DepCase
|
||||
{
|
||||
protected function load()
|
||||
{
|
||||
require DEPLOYER_FIXTURES . '/recipe/release.php';
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
self::$currentPath = self::$tmpPath . '/localhost';
|
||||
}
|
||||
|
||||
public function testReleaseStandard()
|
||||
{
|
||||
$output = $this->start('deploy');
|
||||
self::assertContains('release_path', $output);
|
||||
self::assertNotContains('previous_release', $output);
|
||||
|
||||
$output = $this->start('deploy');
|
||||
self::assertContains('release_path', $output);
|
||||
self::assertContains('previous_release', $output);
|
||||
|
||||
$releasePath = $previousRelease = '';
|
||||
if (preg_match('/release_path (.*)/', $output, $matches)) {
|
||||
$releasePath = $matches[1];
|
||||
}
|
||||
if (preg_match('/previous_release (.*)/', $output, $matches)) {
|
||||
$previousRelease = $matches[1];
|
||||
}
|
||||
self::assertNotSame($releasePath, $previousRelease, "Param release_path shouldn't be equal to previous_release.");
|
||||
}
|
||||
|
||||
public function testReleaseOverrideReleaseName()
|
||||
{
|
||||
self::cleanUp();
|
||||
|
||||
$output = $this->start('deploy', ['-o' => ['release_name=a']]);
|
||||
self::assertContains('release_path', $output);
|
||||
self::assertNotContains('previous_release', $output);
|
||||
|
||||
$output = $this->start('deploy', ['-o' => ['release_name=b']]);
|
||||
self::assertContains('release_path', $output);
|
||||
self::assertContains('previous_release', $output);
|
||||
|
||||
$releasePath = $previousRelease = '';
|
||||
if (preg_match('/release_path (.*)/', $output, $matches)) {
|
||||
$releasePath = $matches[1];
|
||||
}
|
||||
if (preg_match('/previous_release (.*)/', $output, $matches)) {
|
||||
$previousRelease = $matches[1];
|
||||
}
|
||||
self::assertNotSame($releasePath, $previousRelease, "Param release_path shouldn't be equal to previous_release.");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user