Skip to content

Commit 2bc44ac

Browse files
committed
Moved utilities tests from BATS to PHPUnit.
1 parent b4e3d1e commit 2bc44ac

3 files changed

Lines changed: 80 additions & 63 deletions

File tree

.vortex/tests/bats/workflow.utilities.bats

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DrevOps\Vortex\Tests\Functional;
6+
7+
use AlexSkrypnyk\File\File;
8+
9+
/**
10+
* Tests workflow utilities.
11+
*/
12+
class WorkflowUtilitiesTest extends FunctionalTestCase {
13+
14+
protected function setUp(): void {
15+
static::logSection('TEST START | ' . $this->name(), double_border: TRUE);
16+
17+
parent::setUp();
18+
19+
chdir(static::$sut);
20+
21+
$this->stepPrepareSut();
22+
}
23+
24+
protected function tearDown(): void {
25+
parent::tearDown();
26+
27+
static::logSection('TEST DONE | ' . $this->name(), double_border: TRUE);
28+
}
29+
30+
/**
31+
* Test local Ahoy commands functionality.
32+
*/
33+
public function testLocalAhoyCommands(): void {
34+
$this->logSubstep('Assert calling local commands without local file does not throw error');
35+
$this->processRun('ahoy --version');
36+
$this->assertProcessSuccessful();
37+
$this->assertProcessOutputNotContains('[fatal]');
38+
39+
$this->logSubstep('Assert calling local commands with local file path specified and file is present works correctly');
40+
File::copy('.ahoy.local.example.yml', '.ahoy.local.yml');
41+
$this->processRun('ahoy local help');
42+
$this->assertProcessSuccessful();
43+
$this->assertProcessOutputContains('Custom local commands');
44+
$this->assertProcessOutputNotContains('[fatal]');
45+
46+
$this->logSubstep('Assert calling local commands with local file path specified and file is present and file return non-zero exit code');
47+
$local_command_content = <<<YAML
48+
49+
mylocalcommand:
50+
cmd: |
51+
echo 'expected failure'
52+
exit 1
53+
YAML;
54+
$existing_content = File::read('.ahoy.local.yml');
55+
$this->assertNotEmpty($existing_content, 'Failed to read .ahoy.local.yml');
56+
57+
File::dump('.ahoy.local.yml', $existing_content . $local_command_content);
58+
59+
$this->processRun('ahoy local mylocalcommand');
60+
$this->assertProcessFailed();
61+
$this->assertProcessOutputContains('expected failure');
62+
$this->assertProcessOutputNotContains('[fatal]');
63+
}
64+
65+
/**
66+
* Test doctor info command.
67+
*/
68+
public function testDoctorInfo(): void {
69+
$this->logSubstep('Run ahoy doctor info');
70+
$this->processRun('ahoy doctor info');
71+
$this->assertProcessSuccessful();
72+
$this->assertProcessOutputContains('System information report');
73+
$this->assertProcessOutputContains('OPERATING SYSTEM');
74+
$this->assertProcessOutputContains('DOCKER');
75+
$this->assertProcessOutputContains('DOCKER COMPOSE');
76+
$this->assertProcessOutputContains('PYGMY');
77+
$this->assertProcessOutputContains('AHOY');
78+
}
79+
80+
}

.vortex/tests/test.workflow.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ case ${index} in
6363
;;
6464

6565
3)
66-
bats "${TEST_DIR}"/bats/workflow.utilities.bats
6766
# Disabled due to intermittent failures.
6867
# @see https://github.com/drevops/vortex/issues/893
6968
# bats "${TEST_DIR}"/bats/workflow.storage.image_cached.bats
@@ -78,6 +77,5 @@ case ${index} in
7877
# Disabled due to intermittent failures.
7978
# @see https://github.com/drevops/vortex/issues/893
8079
# bats "${TEST_DIR}"/bats/workflow.storage.image_cached.bats
81-
bats "${TEST_DIR}"/bats/workflow.utilities.bats
8280
;;
8381
esac

0 commit comments

Comments
 (0)