Skip to content

Commit

Permalink
Merge pull request #9627 from owncloud/cli-remove-file-versions-by-fi…
Browse files Browse the repository at this point in the history
…leid

[tests-only][full-ci] adding test to remove old versions of a file using file-id using cli command
  • Loading branch information
saw-jan authored Jul 18, 2024
2 parents 698d24c + 22be9de commit 61f8b20
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/acceptance/features/bootstrap/CliContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*/
class CliContext implements Context {
private FeatureContext $featureContext;
private SpacesContext $spacesContext;

/**
* @BeforeScenario
Expand All @@ -45,6 +46,7 @@ public function setUpScenario(BeforeScenarioScope $scope): void {
$environment = $scope->getEnvironment();
// Get all the contexts you need in this context
$this->featureContext = $environment->getContext('FeatureContext');
$this->spacesContext = $environment->getContext('SpacesContext');
}

/**
Expand Down Expand Up @@ -118,6 +120,25 @@ public function theAdministratorRemovesAllVersionsOfResources() {
$this->featureContext->setResponse(CliHelper::runCommand($body));
}

/**
* @When the administrator removes the versions of file :file of user :user from space :space using the CLI
*
* @param string $file
* @param string $user
* @param string $space
*
* @return void
*/
public function theAdministratorRemovesTheVersionsOfFileUsingFileId($file, $user, $space) {
$path = $this->featureContext->getStorageUsersRoot();
$fileId = $this->spacesContext->getFileId($user, $space, $file);
$command = "revisions purge -p $path -r $fileId --dry-run=false";
$body = [
"command" => $command
];
$this->featureContext->setResponse(CliHelper::runCommand($body));
}

/**
* @Then the command should be successful
*
Expand Down
19 changes: 19 additions & 0 deletions tests/acceptance/features/cliCommands/removeFileVersions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,22 @@ Feature: remove file versions via CLI command
When user "Alice" gets the number of versions of file "textfile.txt"
Then the HTTP status code should be "207"
And the number of versions should be "0"


Scenario: remove all versions of file using file-id
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 "randomFile.txt"
And user "Alice" has uploaded file with content "This is version 2" to "randomFile.txt"
And user "Alice" has uploaded file with content "This is version 3" to "randomFile.txt"
And user "Alice" has uploaded file with content "This is version 1" to "anotherFile.txt"
And user "Alice" has uploaded file with content "This is version 2" to "anotherFile.txt"
And user "Alice" has uploaded file with content "This is version 3" to "anotherFile.txt"
When the administrator removes the versions of file "randomFile.txt" of user "Alice" from space "Personal" using the CLI
Then the command should be successful
And the command output should contain "✅ Deleted 2 revisions (6 files / 2 blobs)"
When user "Alice" gets the number of versions of file "randomFile.txt"
Then the HTTP status code should be "207"
And the number of versions should be "0"
When user "Alice" gets the number of versions of file "anotherFile.txt"
Then the HTTP status code should be "207"
And the number of versions should be "2"

0 comments on commit 61f8b20

Please sign in to comment.