From ac8bd3d4c3fe1f6a30578814361806636e1d5615 Mon Sep 17 00:00:00 2001 From: Dwayne Coussement Date: Fri, 4 Jun 2021 16:47:23 +0200 Subject: [PATCH 1/2] MessageAttributes are optional --- Sources/AWSLambdaEvents/SNS.swift | 2 +- Tests/AWSLambdaEventsTests/SNSTests.swift | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/AWSLambdaEvents/SNS.swift b/Sources/AWSLambdaEvents/SNS.swift index 9db4c8f4..a7ec21f6 100644 --- a/Sources/AWSLambdaEvents/SNS.swift +++ b/Sources/AWSLambdaEvents/SNS.swift @@ -49,7 +49,7 @@ public enum SNS { public let messageId: String public let type: String public let topicArn: String - public let messageAttributes: [String: Attribute] + public let messageAttributes: [String: Attribute]? public let signatureVersion: String @ISO8601WithFractionalSecondsCoding diff --git a/Tests/AWSLambdaEventsTests/SNSTests.swift b/Tests/AWSLambdaEventsTests/SNSTests.swift index 3830baed..886f5be6 100644 --- a/Tests/AWSLambdaEventsTests/SNSTests.swift +++ b/Tests/AWSLambdaEventsTests/SNSTests.swift @@ -74,9 +74,9 @@ class SNSTests: XCTestCase { XCTAssertEqual(record.sns.signingCertURL, "https://sns.eu-central-1.amazonaws.com/SimpleNotificationService-6aad65c2f9911b05cd53efda11f913f9.pem") XCTAssertEqual(record.sns.unsubscribeUrl, "https://sns.eu-central-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-central-1:079477498937:EventSources-SNSTopic-1NHENSE2MQKF5:6fabdb7f-b27e-456d-8e8a-14679db9e40c") - XCTAssertEqual(record.sns.messageAttributes.count, 2) + XCTAssertEqual(record.sns.messageAttributes?.count, 2) - XCTAssertEqual(record.sns.messageAttributes["binary"], .binary([UInt8]("base64".utf8))) - XCTAssertEqual(record.sns.messageAttributes["string"], .string("abc123")) + XCTAssertEqual(record.sns.messageAttributes?["binary"], .binary([UInt8]("base64".utf8))) + XCTAssertEqual(record.sns.messageAttributes?["string"], .string("abc123")) } } From cef771ce2e5cecba1249ddd9da1373816b228576 Mon Sep 17 00:00:00 2001 From: Dwayne Coussement Date: Fri, 4 Jun 2021 16:54:37 +0200 Subject: [PATCH 2/2] Remove tabs --- Tests/AWSLambdaEventsTests/SNSTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/AWSLambdaEventsTests/SNSTests.swift b/Tests/AWSLambdaEventsTests/SNSTests.swift index 886f5be6..916a69ea 100644 --- a/Tests/AWSLambdaEventsTests/SNSTests.swift +++ b/Tests/AWSLambdaEventsTests/SNSTests.swift @@ -74,7 +74,7 @@ class SNSTests: XCTestCase { XCTAssertEqual(record.sns.signingCertURL, "https://sns.eu-central-1.amazonaws.com/SimpleNotificationService-6aad65c2f9911b05cd53efda11f913f9.pem") XCTAssertEqual(record.sns.unsubscribeUrl, "https://sns.eu-central-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-central-1:079477498937:EventSources-SNSTopic-1NHENSE2MQKF5:6fabdb7f-b27e-456d-8e8a-14679db9e40c") - XCTAssertEqual(record.sns.messageAttributes?.count, 2) + XCTAssertEqual(record.sns.messageAttributes?.count, 2) XCTAssertEqual(record.sns.messageAttributes?["binary"], .binary([UInt8]("base64".utf8))) XCTAssertEqual(record.sns.messageAttributes?["string"], .string("abc123"))