Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only][full-ci] adding test to remove old versions of files from a space using space-id using CLI #9639

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 "LOREM_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 "EPSUM_FILEID"
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/<<LOREM_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/<<EPSUM_FILEID>>/v"
Then the HTTP status code should be "207"
And the number of versions should be "0"