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 d48cae6 commit be7365e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
18 changes: 18 additions & 0 deletions tests/acceptance/features/bootstrap/CliContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,24 @@ public function theAdministratorReindexesASpaceUsingTheCli(string $spaceName): v
$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
38 changes: 34 additions & 4 deletions tests/acceptance/features/cliCommands/removeFileVersions.feature
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
@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 a space
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 "lorem.txt"
And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 2" to "lorem.txt"
And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 3" to "lorem.txt"
And we save it into "FILEID"
And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 1" to "epsum.txt"
And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 2" to "epsum.txt"
And user "Alice" has uploaded a file inside space "projectSpace" with content "This is version 3" to "epsum.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 "lorem.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 "epsum.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 be7365e

Please sign in to comment.