[Nostromo] Improve tests and coverage

This commit is contained in:
Andrés Montañez
2017-01-04 22:21:38 -03:00
parent b56e1c378c
commit f4f8bfbf05
5 changed files with 98 additions and 6 deletions
@@ -12,8 +12,10 @@ namespace Mage\Tests\Command\BuiltIn\Releases;
use Mage\Command\BuiltIn\Releases\RollbackCommand;
use Mage\Command\AbstractCommand;
use Mage\Runtime\Exception\DeploymentException;
use Mage\Tests\MageApplicationMockup;
use Symfony\Component\Console\Tester\CommandTester;
use Exception;
use PHPUnit_Framework_TestCase as TestCase;
class RollbackCommandTest extends TestCase
@@ -45,4 +47,38 @@ class RollbackCommandTest extends TestCase
$this->assertEquals($command, $ranCommands[$index]);
}
}
public function testRollbackReleaseWithInvalidEnvironment()
{
$application = new MageApplicationMockup();
$application->configure(__DIR__ . '/../../../Resources/testhost.yml');
/** @var AbstractCommand $command */
$command = $application->find('releases:rollback');
$this->assertTrue($command instanceof RollbackCommand);
$tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'developers', 'release' => '20170101015115']);
$this->assertNotEquals(0, $tester->getStatusCode());
$this->assertContains('The environment "developers" does not exists.', $tester->getDisplay());
}
public function testRollbackReleaseWithoutReleases()
{
$application = new MageApplicationMockup();
$application->configure(__DIR__ . '/../../../Resources/testhost-without-releases.yml');
/** @var AbstractCommand $command */
$command = $application->find('releases:rollback');
$this->assertTrue($command instanceof RollbackCommand);
try {
$tester = new CommandTester($command);
$tester->execute(['command' => $command->getName(), 'environment' => 'test', 'release' => '20170101015115']);
} catch (Exception $exception) {
$this->assertTrue($exception instanceof DeploymentException);
$this->assertEquals('Releases are not enabled', $exception->getMessage());
}
}
}