adding test for backup consistency cli command

This commit is contained in:
Niraj Acharya
2024-07-11 12:28:52 +05:45
parent d3515354c8
commit 735b24fff5
4 changed files with 59 additions and 0 deletions
@@ -86,6 +86,20 @@ class CliContext implements Context {
$this->featureContext->updateUserPassword($user, $password);
}
/**
* @When the administrator checks the backup consistency using the CLI
*
* @return void
*/
public function theAdministratorChecksTheBackupConsistencyUsingTheCli():void {
$path = $this->featureContext->getStorageUsersRoot();
$command = "backup consistency -p $path";
$body = [
"command" => $command
];
$this->featureContext->setResponse(CliHelper::runCommand($body));
}
/**
* @Then the command should be successful
*
@@ -112,6 +126,7 @@ class CliContext implements Context {
public function theCommandOutputShouldContain(string $shouldOrNot, string $output): void {
$response = $this->featureContext->getResponse();
$jsonResponse = $this->featureContext->getJsonDecodedResponse($response);
$output = $this->featureContext->substituteInLineCodes($output);
if ($shouldOrNot === "should") {
Assert::assertStringContainsString($output, $jsonResponse["message"]);
@@ -794,6 +794,14 @@ class FeatureContext extends BehatVariablesContext {
return $this->baseUrl;
}
/**
* @return string
*/
public function getStorageUsersRoot(): string {
$ocisDataPath = getenv("OCIS_BASE_DATA_PATH") ? getenv("OCIS_BASE_DATA_PATH") : getenv("HOME") . '/.ocis';
return getenv("STORAGE_USERS_OCIS_ROOT") ? getenv("STORAGE_USERS_OCIS_ROOT") : $ocisDataPath . "/storage/users";
}
/**
* returns the path of the base URL
* e.g. owncloud-core/10 if the baseUrl is http://localhost/owncloud-core/10
@@ -2072,6 +2080,14 @@ class FeatureContext extends BehatVariablesContext {
],
"parameter" => []
],
[
"code" => "%storage_path%",
"function" => [
$this,
"getStorageUsersRoot"
],
"parameter" => []
],
[
"code" => "%base_url_without_scheme%",
"function" => [