|
14 | 14 | use Hammerstone\Sidecar\Events\BeforeFunctionsDeployed; |
15 | 15 | use Hammerstone\Sidecar\Exceptions\NoFunctionsRegisteredException; |
16 | 16 | use Hammerstone\Sidecar\Tests\Unit\Support\DeploymentTestFunction; |
| 17 | +use Hammerstone\Sidecar\Tests\Unit\Support\DeploymentTestFunctionWithTags; |
17 | 18 | use Hammerstone\Sidecar\Tests\Unit\Support\DeploymentTestFunctionWithVariables; |
18 | 19 | use Illuminate\Support\Facades\Event; |
19 | 20 | use Mockery; |
@@ -63,7 +64,8 @@ public function mockCreatingFunction() |
63 | 64 | 'MemorySize' => 'test-MemorySize', |
64 | 65 | 'Layers' => 'test-Layers', |
65 | 66 | 'Publish' => 'test-Publish', |
66 | | - 'Architectures' => ['x86_64'] |
| 67 | + 'Architectures' => ['x86_64'], |
| 68 | + 'Tags' => [], |
67 | 69 | ]); |
68 | 70 |
|
69 | 71 | $this->lambda->shouldNotReceive('updateFunctionConfiguration'); |
@@ -269,6 +271,59 @@ public function it_doesnt_change_variables_that_havent_changed() |
269 | 271 | $this->assertEvents($deployed = true, $activated = true); |
270 | 272 | } |
271 | 273 |
|
| 274 | + /** @test */ |
| 275 | + public function it_sets_function_tags() |
| 276 | + { |
| 277 | + $this->lambda->shouldReceive('functionExists')->andReturn(false); |
| 278 | + $this->lambda->shouldReceive('getVersions')->andReturn([]); |
| 279 | + |
| 280 | + $this->lambda->shouldReceive('createFunction')->once()->with([ |
| 281 | + 'FunctionName' => 'test-FunctionName', |
| 282 | + 'Runtime' => 'test-Runtime', |
| 283 | + 'Role' => 'test-Role', |
| 284 | + 'Handler' => 'test-Handler', |
| 285 | + 'Code' => [ |
| 286 | + 'S3Bucket' => 'test-bucket', |
| 287 | + 'S3Key' => 'test-key', |
| 288 | + ], |
| 289 | + 'Description' => 'test-Description', |
| 290 | + 'Timeout' => 'test-Timeout', |
| 291 | + 'MemorySize' => 'test-MemorySize', |
| 292 | + 'EphemeralStorage' => [ |
| 293 | + 'Size' => 'test-EphemeralStorage' |
| 294 | + ], |
| 295 | + 'Layers' => 'test-Layers', |
| 296 | + 'Publish' => 'test-Publish', |
| 297 | + 'Architectures' => ['x86_64'], |
| 298 | + 'Tags' => [ |
| 299 | + 'Project' => 'Super Secret Project', |
| 300 | + ], |
| 301 | + ]); |
| 302 | + |
| 303 | + $this->lambda->shouldNotReceive('updateFunctionConfiguration'); |
| 304 | + $this->lambda->shouldNotReceive('updateFunctionCode'); |
| 305 | + |
| 306 | + $this->lambda->shouldReceive('getLatestVersion') |
| 307 | + ->once() |
| 308 | + ->withArgs(function ($function) { |
| 309 | + return $function instanceof DeploymentTestFunctionWithTags; |
| 310 | + }) |
| 311 | + ->andReturn('10'); |
| 312 | + |
| 313 | + $this->lambda->shouldReceive('aliasVersion') |
| 314 | + ->once() |
| 315 | + ->withArgs(function ($function, $alias, $version) { |
| 316 | + return $function instanceof DeploymentTestFunctionWithTags |
| 317 | + && $alias === 'active' |
| 318 | + && $version === '10'; |
| 319 | + }) |
| 320 | + ->andReturn(LambdaClient::CREATED); |
| 321 | + |
| 322 | + DeploymentTestFunctionWithTags::deploy($activate = true); |
| 323 | + |
| 324 | + $this->assertEvents($deployed = true, $activated = true); |
| 325 | + } |
| 326 | + |
272 | 327 | /** @test */ |
273 | 328 | public function it_throws_an_exception_if_there_are_no_functions() |
274 | 329 | { |
|
0 commit comments