|
3 | 3 | namespace AsyncAws\Lambda\Tests\Integration;
|
4 | 4 |
|
5 | 5 | use AsyncAws\Core\Credentials\NullProvider;
|
| 6 | +use AsyncAws\Core\Result; |
6 | 7 | use AsyncAws\Lambda\Input\AddLayerVersionPermissionRequest;
|
7 | 8 | use AsyncAws\Lambda\Input\InvocationRequest;
|
8 | 9 | use AsyncAws\Lambda\Input\ListLayerVersionsRequest;
|
9 | 10 | use AsyncAws\Lambda\Input\PublishLayerVersionRequest;
|
10 | 11 | use AsyncAws\Lambda\LambdaClient;
|
| 12 | +use AsyncAws\Lambda\Result\InvocationResponse; |
11 | 13 | use AsyncAws\Lambda\ValueObject\LayerVersionContentInput;
|
12 | 14 | use PHPUnit\Framework\TestCase;
|
13 | 15 |
|
@@ -55,6 +57,37 @@ public function testInvoke(): void
|
55 | 57 | self::assertSame('$LATEST', $result->getExecutedVersion());
|
56 | 58 | }
|
57 | 59 |
|
| 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 | + |
58 | 91 | public function testListLayerVersions(): void
|
59 | 92 | {
|
60 | 93 | self::markTestSkipped('The Lambda Docker image does not implement AddLayerVersionPermission.');
|
|
0 commit comments