Skip to content

Commit 9f47296

Browse files
authored
Add multiplexing method (#417)
* Add multiplexing method * Don't throw exceptions * Rename resolveAll into multiplex * Fix lowest test * Fix early return * Add a parameter to download body * Catch exception for each response individually * Throw on __destruct * Apply suggestions * Better handle of recurcion in exception * Fix CS * Rename into wait
1 parent 3e08fdd commit 9f47296

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/Integration/LambdaClientTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
namespace AsyncAws\Lambda\Tests\Integration;
44

55
use AsyncAws\Core\Credentials\NullProvider;
6+
use AsyncAws\Core\Result;
67
use AsyncAws\Lambda\Input\AddLayerVersionPermissionRequest;
78
use AsyncAws\Lambda\Input\InvocationRequest;
89
use AsyncAws\Lambda\Input\ListLayerVersionsRequest;
910
use AsyncAws\Lambda\Input\PublishLayerVersionRequest;
1011
use AsyncAws\Lambda\LambdaClient;
12+
use AsyncAws\Lambda\Result\InvocationResponse;
1113
use AsyncAws\Lambda\ValueObject\LayerVersionContentInput;
1214
use PHPUnit\Framework\TestCase;
1315

@@ -55,6 +57,37 @@ public function testInvoke(): void
5557
self::assertSame('$LATEST', $result->getExecutedVersion());
5658
}
5759

60+
public function testInvokeWait(): void
61+
{
62+
if (!\method_exists(Result::class, 'wait')) {
63+
self::markTestSkipped('Core does not contains the feature');
64+
}
65+
66+
$client = $this->getClient();
67+
68+
$results = [];
69+
$expected = [];
70+
for ($i = 0; $i < 10; ++$i) {
71+
$expected[] = '"hello ' . $i . '"';
72+
$results[] = $client->Invoke(new InvocationRequest([
73+
'FunctionName' => 'Index',
74+
'Payload' => \json_encode(['name' => $i]),
75+
]));
76+
}
77+
78+
$resolves = [];
79+
/** @var InvocationResponse[] $result */
80+
foreach (Result::wait($results, null, true) as $index => $result) {
81+
// assert $index match original order
82+
self::assertSame($expected[$index], $result->getPayload());
83+
$resolves[] = $result->getPayload();
84+
}
85+
86+
self::assertEqualsCanonicalizing($expected, $resolves);
87+
// wait should mix responses
88+
self::assertNotEquals($expected, $resolves);
89+
}
90+
5891
public function testListLayerVersions(): void
5992
{
6093
self::markTestSkipped('The Lambda Docker image does not implement AddLayerVersionPermission.');

0 commit comments

Comments
 (0)