Skip to content

Commit 202f913

Browse files
author
DwayneCoussement
authored
SNS MessageAttributes are optional (#208)
motivation: Notice that if you check the contents of the SQS records, some kind of transform happened on the original SNS message. MessageAttributes in the above example, these will not be set, so this is the initial fix. changes: make MessageAttributes are optional
1 parent 53ad717 commit 202f913

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Sources/AWSLambdaEvents/SNS.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public enum SNS {
4949
public let messageId: String
5050
public let type: String
5151
public let topicArn: String
52-
public let messageAttributes: [String: Attribute]
52+
public let messageAttributes: [String: Attribute]?
5353
public let signatureVersion: String
5454

5555
@ISO8601WithFractionalSecondsCoding

Tests/AWSLambdaEventsTests/SNSTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ class SNSTests: XCTestCase {
7474
XCTAssertEqual(record.sns.signingCertURL, "https://sns.eu-central-1.amazonaws.com/SimpleNotificationService-6aad65c2f9911b05cd53efda11f913f9.pem")
7575
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")
7676

77-
XCTAssertEqual(record.sns.messageAttributes.count, 2)
77+
XCTAssertEqual(record.sns.messageAttributes?.count, 2)
7878

79-
XCTAssertEqual(record.sns.messageAttributes["binary"], .binary([UInt8]("base64".utf8)))
80-
XCTAssertEqual(record.sns.messageAttributes["string"], .string("abc123"))
79+
XCTAssertEqual(record.sns.messageAttributes?["binary"], .binary([UInt8]("base64".utf8)))
80+
XCTAssertEqual(record.sns.messageAttributes?["string"], .string("abc123"))
8181
}
8282
}

0 commit comments

Comments
 (0)