Skip to content

Commit ae86655

Browse files
committed
Add test for uninstall command
Signed-off-by: Kirtan Gajjar <[email protected]>
1 parent b5906a5 commit ae86655

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

features/bootstrap/FeatureContext.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
use Behat\Behat\Hook\Scope\AfterFeatureScope;
88

99

10-
use Behat\Gherkin\Node\PyStringNode,
11-
Behat\Gherkin\Node\TableNode;
10+
use Behat\Gherkin\Node\PyStringNode;
1211

1312
class FeatureContext implements Context
1413
{
@@ -93,7 +92,27 @@ public function stdoutShouldReturnSomethingLike($output_stream, PyStringNode $ex
9392
}
9493
}
9594

96-
95+
/**
96+
* @Then ee should be deleted
97+
*/
98+
public function eeShouldBeDeleted()
99+
{
100+
$result = EE::launch("docker ps -aqf label=org.label-schema.vendor=\"EasyEngine\" | wc -l", false, true);
101+
if( trim($result->stdout) !== '0' ) {
102+
throw new Exception("All containers have not been removed.");
103+
}
104+
$home = getenv('HOME');
105+
if(file_exists("$home/.ee/")){
106+
throw new Exception("~/.ee/ has not been removed");
107+
}
108+
if(file_exists("$home/ee-sites/")){
109+
throw new Exception("~/ee-sites/ has not been removed");
110+
}
111+
if(file_exists(EE_CONF_ROOT)){
112+
throw new Exception(EE_CONF_ROOT . "has not been removed");
113+
}
114+
}
115+
97116
/**
98117
* @AfterFeature
99118
*/

features/cli.feature

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ Feature: CLI Command
1313
Scenario: ee update works properly
1414
Given ee phar is generated
1515
When I run 'sudo php ee.phar cli update --yes'
16-
Then return value should be 0
16+
Then return value should be 0
17+
18+
Scenario: ee uninstall works properly
19+
When I run 'sudo bin/ee cli self-uninstall --yes'
20+
Then ee should be deleted

php/commands/src/CLI_Command.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,17 @@ public function cmd_dump() {
491491
/**
492492
* Uninstalls easyengine completely along with all sites
493493
*
494+
* ## OPTIONS
495+
*
496+
* [--yes]
497+
* : Do not prompt for confirmation.
498+
*
494499
* @subcommand self-uninstall
495500
*/
496-
public function self_uninstall() {
497-
EE::confirm("Are you sure you want to remove EasyEngine and all its sites(along with their data) ?");
501+
public function self_uninstall( $args, $assoc_args ) {
502+
503+
EE::confirm("Are you sure you want to remove EasyEngine and all its sites(along with their data) ?", $assoc_args);
504+
498505
Utils\default_launch("docker rm -f $(docker ps -aqf label=org.label-schema.vendor=\"EasyEngine\")");
499506
$home = Utils\get_home_dir();
500507
Utils\default_launch("rm -rf $home/.ee/");

0 commit comments

Comments
 (0)