Skip to content

Commit d06ca73

Browse files
authored
Merge pull request #11597 from owncloud/tests/postprocessing-cli-command
[tests-only][full-ci] add tests for postprocessing cli command
2 parents 8abef52 + 07c02a6 commit d06ca73

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

tests/acceptance/bootstrap/CliContext.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ public function theAdministratorResumesOrRestartsUploadSessionOfFileUsingTheCLI(
414414
foreach ($responseArray as $item) {
415415
if ($item->filename === $file) {
416416
$uploadId = $item->id;
417+
break;
417418
}
418419
}
419420

@@ -424,6 +425,37 @@ public function theAdministratorResumesOrRestartsUploadSessionOfFileUsingTheCLI(
424425
$this->featureContext->setResponse(CliHelper::runCommand($body));
425426
}
426427

428+
/**
429+
* @When /^the administrator (resumes|restarts) the upload session of file "([^"]*)" using postprocessing command$/
430+
*
431+
* @param string $flag
432+
* @param string $file
433+
*
434+
* @return void
435+
* @throws JsonException
436+
*/
437+
public function theAdministratorResumesOrRestartsUploadSessionOfFileUsingPostprocessingCommand(
438+
string $flag,
439+
string $file,
440+
): void {
441+
$uploadSessions = CliHelper::runCommand(["command" => "storage-users uploads sessions --json"]);
442+
$this->featureContext->theHTTPStatusCodeShouldBe(200, '', $uploadSessions);
443+
$responseArray = $this->getJSONDecodedCliMessage($uploadSessions);
444+
445+
foreach ($responseArray as $item) {
446+
if ($item->filename === $file) {
447+
$uploadId = $item->id;
448+
break;
449+
}
450+
}
451+
452+
$command = "postprocessing resume" . ($flag === "restarts" ? " -r" : "") . " -u $uploadId";
453+
$body = [
454+
"command" => $command,
455+
];
456+
$this->featureContext->setResponse(CliHelper::runCommand($body));
457+
}
458+
427459
/**
428460
* @Then /^the CLI response (should|should not) contain these entries:$/
429461
*

tests/acceptance/features/cliCommands/uploadSessions.feature

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,37 @@ Feature: List upload sessions via CLI command
211211
| large.zip |
212212
And the CLI response should not contain these entries:
213213
| file.txt |
214+
215+
216+
Scenario: resume a specific upload session using postprocessing command
217+
Given the config "POSTPROCESSING_DELAY" has been set to "3s"
218+
And user "Alice" has uploaded file with content "uploaded content" to "file1.txt"
219+
And user "Alice" has uploaded file with content "uploaded content" to "file2.txt"
220+
And the administrator has waited for "1" seconds
221+
And the administrator has stopped the server
222+
And the administrator has started the server
223+
When the administrator waits for "3" seconds
224+
Then for user "Alice" file "file1.txt" of space "Personal" should be in postprocessing
225+
And for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing
226+
When the administrator resumes the upload session of file "file1.txt" using postprocessing command
227+
Then the command should be successful
228+
When the administrator waits for "3" seconds
229+
Then for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing
230+
And the content of file "file1.txt" for user "Alice" should be "uploaded content"
231+
232+
233+
Scenario: restart a specific upload session using postprocessing command
234+
Given the config "POSTPROCESSING_DELAY" has been set to "3s"
235+
And user "Alice" has uploaded file with content "uploaded content" to "file1.txt"
236+
And user "Alice" has uploaded file with content "uploaded content" to "file2.txt"
237+
And the administrator has waited for "1" seconds
238+
And the administrator has stopped the server
239+
And the administrator has started the server
240+
When the administrator waits for "3" seconds
241+
Then for user "Alice" file "file1.txt" of space "Personal" should be in postprocessing
242+
And for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing
243+
When the administrator restarts the upload session of file "file1.txt" using postprocessing command
244+
Then the command should be successful
245+
When the administrator waits for "3" seconds
246+
Then for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing
247+
And the content of file "file1.txt" for user "Alice" should be "uploaded content"

0 commit comments

Comments
 (0)