Skip to content

Commit

Permalink
add test to remove versions using CLI command
Browse files Browse the repository at this point in the history
Signed-off-by: prashant-gurung899 <[email protected]>
  • Loading branch information
prashant-gurung899 committed Jul 11, 2024
1 parent d57ff92 commit 2ec5c22
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/acceptance/features/bootstrap/CliContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ public function theAdministratorResetsThePasswordOfUserUsingTheCLI(string $user,
$this->featureContext->updateUserPassword($user, $password);
}

/**
* @When user :arg1 removes all versions of resources
*/
public function userRemovesAllVersionsOfResources($arg1) {
$path = $this->featureContext->getStorageUsersRoot();
$command = "revisions purge -p $path --dry-run=false";
$body = [
"command" => $command
];
$this->featureContext->setResponse(CliHelper::runCommand($body));
}

/**
* @Then the command should be successful
*
Expand Down
8 changes: 8 additions & 0 deletions tests/acceptance/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,14 @@ public function getBaseUrl(): string {
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
Expand Down
12 changes: 12 additions & 0 deletions tests/acceptance/features/cliCommands/removeVersions.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: remove versions via CLI command


Scenario: remove all versions of files in storage
Given user "Alice" has been created with default attributes and without skeleton files
And user "Alice" has uploaded file with content "This is version 1" to "textfile.txt"
And user "Alice" has uploaded file with content "This is version 2" to "textfile.txt"
And user "Alice" has uploaded file with content "This is version 3" to "textfile.txt"
And the administrator has stopped the server
When user "Alice" removes all versions of resources
Then the command should be successful
And the command output should contain "✅ Deleted 2 revisions (6 files / 2 blobs)"

0 comments on commit 2ec5c22

Please sign in to comment.