Add oncePerNode() test

This commit is contained in:
Anton Medvedev 2021-10-12 22:47:59 +02:00
parent 70733a42b7
commit 82c2b44561
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,25 @@
<?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;
class OncePerNodeTest extends AbstractTest
{
const RECIPE = __DIR__ . '/recipe/once_per_node.php';
public function testOnce()
{
$this->dep(self::RECIPE, 'test_once_per_node');
$display = $this->tester->getDisplay();
self::assertEquals(0, $this->tester->getStatusCode(), $display);
self::assertStringContainsString('alias: group_a_1 hostname: localhost', $display);
self::assertStringNotContainsString('alias: group_a_2 hostname: localhost', $display);
self::assertStringContainsString('alias: group_b_1 hostname: group_b_1', $display);
self::assertStringNotContainsString('alias: group_b_2 hostname: group_b_2', $display);
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace Deployer;
localhost('group_a_1')
->setHostname('localhost');
localhost('group_a_2')
->setHostname('localhost');
localhost('group_b_1')
->setLabels(['node' => 'anna']);
localhost('group_b_2')
->setLabels(['node' => 'anna']);
task('test_once_per_node', function () {
writeln('alias: {{alias}} hostname: {{hostname}}');
})->oncePerNode();