Skip to content

Commit 07c02a6

Browse files
committed
add tests for postprocessing cli command
Signed-off-by: nabim777 <[email protected]>
1 parent 9b0926e commit 07c02a6

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
@@ -412,6 +412,7 @@ public function theAdministratorRestartsUploadSessionsOfFile(string $file): void
412412
foreach ($responseArray as $item) {
413413
if ($item->filename === $file) {
414414
$uploadId = $item->id;
415+
break;
415416
}
416417
}
417418

@@ -422,6 +423,37 @@ public function theAdministratorRestartsUploadSessionsOfFile(string $file): void
422423
$this->featureContext->setResponse(CliHelper::runCommand($body));
423424
}
424425

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

tests/acceptance/features/cliCommands/uploadSessions.feature

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,37 @@ Feature: List upload sessions via CLI command
190190
| large.zip |
191191
And the CLI response should not contain these entries:
192192
| file.txt |
193+
194+
195+
Scenario: resume a specific upload session using postprocessing command
196+
Given the config "POSTPROCESSING_DELAY" has been set to "3s"
197+
And user "Alice" has uploaded file with content "uploaded content" to "file1.txt"
198+
And user "Alice" has uploaded file with content "uploaded content" to "file2.txt"
199+
And the administrator has waited for "1" seconds
200+
And the administrator has stopped the server
201+
And the administrator has started the server
202+
When the administrator waits for "3" seconds
203+
Then for user "Alice" file "file1.txt" of space "Personal" should be in postprocessing
204+
And for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing
205+
When the administrator resumes the upload session of file "file1.txt" using postprocessing command
206+
Then the command should be successful
207+
When the administrator waits for "3" seconds
208+
Then for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing
209+
And the content of file "file1.txt" for user "Alice" should be "uploaded content"
210+
211+
212+
Scenario: restart a specific upload session using postprocessing command
213+
Given the config "POSTPROCESSING_DELAY" has been set to "3s"
214+
And user "Alice" has uploaded file with content "uploaded content" to "file1.txt"
215+
And user "Alice" has uploaded file with content "uploaded content" to "file2.txt"
216+
And the administrator has waited for "1" seconds
217+
And the administrator has stopped the server
218+
And the administrator has started the server
219+
When the administrator waits for "3" seconds
220+
Then for user "Alice" file "file1.txt" of space "Personal" should be in postprocessing
221+
And for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing
222+
When the administrator restarts the upload session of file "file1.txt" using postprocessing command
223+
Then the command should be successful
224+
When the administrator waits for "3" seconds
225+
Then for user "Alice" file "file2.txt" of space "Personal" should be in postprocessing
226+
And the content of file "file1.txt" for user "Alice" should be "uploaded content"

0 commit comments

Comments
 (0)