Skip to content

Commit

Permalink
add test to remove versions of files from space using space id
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 19, 2024
1 parent 61f8b20 commit 86e7382
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 7 deletions.
22 changes: 20 additions & 2 deletions tests/acceptance/features/bootstrap/CliContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function theAdministratorChecksTheBackupConsistencyUsingTheCli():void {
*
* @return void
*/
public function theAdministratorRemovesAllVersionsOfResources() {
public function theAdministratorRemovesAllVersionsOfResources():void {
$path = $this->featureContext->getStorageUsersRoot();
$command = "revisions purge -p $path --dry-run=false";
$body = [
Expand All @@ -129,7 +129,7 @@ public function theAdministratorRemovesAllVersionsOfResources() {
*
* @return void
*/
public function theAdministratorRemovesTheVersionsOfFileUsingFileId($file, $user, $space) {
public function theAdministratorRemovesTheVersionsOfFileUsingFileId(string $file, string $user, string $space):void {
$path = $this->featureContext->getStorageUsersRoot();
$fileId = $this->spacesContext->getFileId($user, $space, $file);
$command = "revisions purge -p $path -r $fileId --dry-run=false";
Expand All @@ -139,6 +139,24 @@ public function theAdministratorRemovesTheVersionsOfFileUsingFileId($file, $user
$this->featureContext->setResponse(CliHelper::runCommand($body));
}

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

/**
* @Then the command should be successful
*
Expand Down
40 changes: 35 additions & 5 deletions tests/acceptance/features/cliCommands/removeFileVersions.feature
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
@env-config
#@env-config
Feature: remove file versions via CLI command

Background:
Given user "Alice" has been created with default attributes and without skeleton files


Scenario: remove all file versions
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"
Given 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"
When the administrator removes all the file versions using the CLI
Expand All @@ -16,8 +18,7 @@ Feature: remove file versions via CLI command


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"
Given 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"
Expand All @@ -32,3 +33,32 @@ Feature: remove file versions via CLI command
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"


Scenario: remove all versions of files from space using space-id
Given the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
And using spaces DAV path
And user "Alice" has created a space "projectSpace" with the default quota using the Graph API
And user "Alice" has uploaded file with content "This is version 1" to "file.txt"
And user "Alice" has uploaded file with content "This is version 2" to "file.txt"
And user "Alice" has uploaded file with content "This is version 3" to "file.txt"
And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 1" to "anotherFile.txt"
And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 2" to "anotherFile.txt"
And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 3" to "anotherFile.txt"
And we save it into "FILEID"
And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 1" to "anotherFile1.txt"
And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 2" to "anotherFile1.txt"
And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 3" to "anotherFile1.txt"
And we save it into "FILEID1"
When the administrator removes the file versions of space "projectSpace" using the CLI
Then the command should be successful
And the command output should contain "✅ Deleted 4 revisions (12 files / 4 blobs)"
When user "Alice" gets the number of versions of file "file.txt"
Then the HTTP status code should be "207"
And the number of versions should be "2"
When user "Alice" gets the number of versions of file "anotherFile.txt" using file-id path "/meta/<<FILEID>>/v"
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 "anotherFile1.txt" using file-id path "/meta/<<FILEID1>>/v"
Then the HTTP status code should be "207"
And the number of versions should be "0"

0 comments on commit 86e7382

Please sign in to comment.