Skip to content

Commit 3348e28

Browse files
committed
added logical id
1 parent 790cc89 commit 3348e28

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/IQueueSerializable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Amazon.Lambda.Annotations.SourceGenerator.Models
66
{
77
public interface IQueueSerializable
88
{
9-
string Name { get; set; }
9+
string LogicalId { get; set; }
1010
string QueueName { get; set; }
1111
}
1212
}

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Writers/CloudFormationJsonWriter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void ApplyReport(AnnotationReport report)
5454
if (!ShouldProcessQueue(queueModelSerializable))
5555
continue;
5656
ProcessQueue(queueModelSerializable, relativeProjectUri);
57-
processedQueues.Add(queueModelSerializable.Name);
57+
processedQueues.Add(queueModelSerializable.LogicalId);
5858

5959
}
6060

@@ -81,7 +81,7 @@ private bool ShouldProcessLambdaFunction(ILambdaFunctionSerializable lambdaFunct
8181
}
8282
private bool ShouldProcessQueue(IQueueSerializable queue)
8383
{
84-
var queuePath = $"Resources.{queue.Name}";
84+
var queuePath = $"Resources.{queue.LogicalId}";
8585

8686
if (!_jsonWriter.Exists(queuePath))
8787
return true;
@@ -103,7 +103,7 @@ private void ProcessLambdaFunction(ILambdaFunctionSerializable lambdaFunction, s
103103
}
104104
private void ProcessQueue(IQueueSerializable queue, string relativeProjectUri)
105105
{
106-
var queuePath = $"Resources.{queue.Name}";
106+
var queuePath = $"Resources.{queue.LogicalId}";
107107
var propertiesPath = $"{queuePath}.Properties";
108108

109109
if (!_jsonWriter.Exists(queuePath))

Libraries/test/Amazon.Lambda.Annotations.SourceGenerators.Tests/WriterTests/CloudFormationJsonWriterTests.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,10 @@ public void PackageTypePropertyTest()
379379
[Fact]
380380
public void AddQueueToEmptyTemplate()
381381
{
382+
const string queueLogicalId = "MyQueue";
382383
// ARRANGE
383384
var mockFileManager = GetMockFileManager(string.Empty);
384-
var queueModel = GetQueueModel();
385+
var queueModel = GetQueueModel(queueLogicalId);
385386
var cloudFormationJsonWriter = new CloudFormationJsonWriter(mockFileManager, _mockDirectoryManager, _jsonWriter, _diagnosticReporter);
386387
var report = GetAnnotationReport(new List<IQueueSerializable>() { queueModel });
387388

@@ -390,7 +391,7 @@ public void AddQueueToEmptyTemplate()
390391

391392
// ASSERT
392393
var rootToken = JObject.Parse(mockFileManager.ReadAllText(ServerlessTemplateFilePath));
393-
var queueToken = rootToken["Resources"]["TestQueue"];
394+
var queueToken = rootToken["Resources"][queueLogicalId];
394395
var propertiesToken = queueToken["Properties"];
395396

396397
Assert.Equal("2010-09-09", rootToken["AWSTemplateFormatVersion"]);
@@ -428,9 +429,9 @@ private LambdaFunctionModelTest GetLambdaFunctionModel(string handler, string na
428429
Role = role
429430
};
430431
}
431-
private QueueTest GetQueueModel()
432+
private QueueTest GetQueueModel(string queueLogicalId)
432433
{
433-
return new QueueTest() { Name = "TestQueue", QueueName = "QueueName"};
434+
return new QueueTest() { LogicalId = queueLogicalId, QueueName = "QueueName"};
434435
}
435436

436437
private AnnotationReport GetAnnotationReport(List<ILambdaFunctionSerializable> lambdaFunctionModels)
@@ -477,7 +478,7 @@ public class LambdaFunctionModelTest : ILambdaFunctionSerializable
477478

478479
public class QueueTest : IQueueSerializable
479480
{
480-
public string Name { get; set; }
481+
public string LogicalId { get; set; }
481482
public string QueueName { get; set; }
482483
}
483484
}

0 commit comments

Comments
 (0)