Skip to content

Commit 7138f1b

Browse files
committed
swift format
1 parent 4d77dea commit 7138f1b

9 files changed

+51
-40
lines changed

Tests/AWSLambdaEventsTests/APIGatewayLambdaAuthorizerTest.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ struct APIGatewayLambdaAuthorizerTests {
171171
let data = try #require(try? JSONEncoder().encode(resp))
172172
let stringData = try #require(String(data: data, encoding: .utf8))
173173
let newData = try #require(stringData.data(using: .utf8))
174-
174+
175175
resp = try JSONDecoder().decode(APIGatewayLambdaAuthorizerSimpleResponse.self, from: newData)
176176

177177
#expect(resp.isAuthorized == true)
@@ -195,7 +195,7 @@ struct APIGatewayLambdaAuthorizerTests {
195195
let data = try #require(try? JSONEncoder().encode(resp))
196196
let stringData = try #require(String(data: data, encoding: .utf8))
197197
let newData = try #require(stringData.data(using: .utf8))
198-
198+
199199
resp = try JSONDecoder().decode(APIGatewayLambdaAuthorizerPolicyResponse.self, from: newData)
200200

201201
#expect(resp.principalId == "John Appleseed")
@@ -224,15 +224,14 @@ struct APIGatewayLambdaAuthorizerTests {
224224
let data = try #require(try? JSONEncoder().encode(resp))
225225
let stringData = try #require(try? String(data: data, encoding: .utf8))
226226
let newData = try #require(stringData.data(using: .utf8))
227-
228-
resp = try JSONDecoder().decode(APIGatewayLambdaAuthorizerPolicyResponse.self, from: newData)
227+
228+
resp = try JSONDecoder().decode(APIGatewayLambdaAuthorizerPolicyResponse.self, from: newData)
229229

230230
#expect(resp.principalId == "John Appleseed")
231231
#expect(resp.policyDocument.statement.count == 1)
232232
#expect(resp.policyDocument.statement[0].action == ["execute-api:Invoke"])
233233
#expect(
234-
resp.policyDocument.statement[0].resource ==
235-
[
234+
resp.policyDocument.statement[0].resource == [
236235
"arn:aws:execute-api:*:*:*/*/GET/v1/user/0123",
237236
"arn:aws:execute-api:*:*:*/*/POST/v1/user",
238237
]

Tests/AWSLambdaEventsTests/APIGatewayTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ struct APIGatewayTests {
6868
#expect(req.path == "/test")
6969
#expect(req.httpMethod == .get)
7070
#expect(
71-
req.requestContext.authorizer?.claims?["scope"] == "aws.cognito.signin.user.admin phone openid profile email"
71+
req.requestContext.authorizer?.claims?["scope"]
72+
== "aws.cognito.signin.user.admin phone openid profile email"
7273
)
7374
#expect(req.requestContext.authorizer?.claims?["username"] == "richwolf")
7475
}

Tests/AWSLambdaEventsTests/CloudFormationTests.swift

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
import Testing
16+
17+
@testable import AWSLambdaEvents
18+
1519
#if canImport(FoundationEssentials)
1620
import FoundationEssentials
1721
#else
1822
import Foundation
1923
#endif
20-
import Testing
21-
22-
@testable import AWSLambdaEvents
2324

2425
@Suite
2526
struct CloudFormationTests {
@@ -92,10 +93,11 @@ struct CloudFormationTests {
9293
"{\"Data\":{\"property1\":\"value1\",\"property2\":\"\",\"property3\":[\"1\",\"2\",\"3\"]},\"LogicalResourceId\":\"TestLogicalResource\",\"NoEcho\":false,\"PhysicalResourceId\":\"TestPhysicalResource\",\"Reason\":\"See the details in CloudWatch Log Stream\",\"RequestId\":\"cdc73f9d-aea9-11e3-9d5a-835b769c0d9c\",\"StackId\":\"arn:aws:cloudformation:us-east-1:123456789:stack\\/TestStack\",\"Status\":\"SUCCESS\"}"
9394
}
9495

95-
@Test func decodeRequestRequiredFieldsFromJSON() throws{
96+
@Test func decodeRequestRequiredFieldsFromJSON() throws {
9697
let eventBody = CloudFormationTests.eventBodyRequestRequiredFields()
9798
let data = eventBody.data(using: .utf8)!
98-
let event: CloudFormation.Request<EmptyTestResourceProperties, EmptyTestResourceProperties>? = try JSONDecoder().decode(CloudFormation.Request.self, from: data)
99+
let event: CloudFormation.Request<EmptyTestResourceProperties, EmptyTestResourceProperties>? = try JSONDecoder()
100+
.decode(CloudFormation.Request.self, from: data)
99101

100102
guard let event else {
101103
Issue.record("Expected to have an event")
@@ -115,9 +117,10 @@ struct CloudFormationTests {
115117
@Test func decodeRequestCreateFromJSON() throws {
116118
let eventBody = CloudFormationTests.eventBodyRequestCreate()
117119
let data = eventBody.data(using: .utf8)!
118-
let event: CloudFormation.Request<TestResourceProperties, EmptyTestResourceProperties>? = try? JSONDecoder().decode(CloudFormation.Request.self, from: data)
120+
let event: CloudFormation.Request<TestResourceProperties, EmptyTestResourceProperties>? = try? JSONDecoder()
121+
.decode(CloudFormation.Request.self, from: data)
119122

120-
guard let event else {
123+
guard let event else {
121124
Issue.record("Expected to have an event")
122125
return
123126
}
@@ -138,9 +141,12 @@ struct CloudFormationTests {
138141
@Test func decodeRequestUpdateFromJSON() throws {
139142
let eventBody = CloudFormationTests.eventBodyRequestUpdate()
140143
let data = eventBody.data(using: .utf8)!
141-
let event: CloudFormation.Request<TestResourceProperties, TestResourceProperties>? = try? JSONDecoder().decode(CloudFormation.Request.self, from: data)
144+
let event: CloudFormation.Request<TestResourceProperties, TestResourceProperties>? = try? JSONDecoder().decode(
145+
CloudFormation.Request.self,
146+
from: data
147+
)
142148

143-
guard let event else {
149+
guard let event else {
144150
Issue.record("Expected to have an event")
145151
return
146152
}

Tests/AWSLambdaEventsTests/DynamoDBTests.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,11 @@ struct DynamoDBTests {
212212
value = try JSONDecoder().decode(DynamoDBEvent.AttributeValue.self, from: json.data(using: .utf8)!)
213213
}
214214
#expect(
215-
value == .map([
216-
"numbers": .numberSet(["1.2345", "-19"]),
217-
"string": .string("huhu"),
218-
])
215+
value
216+
== .map([
217+
"numbers": .numberSet(["1.2345", "-19"]),
218+
"string": .string("huhu"),
219+
])
219220
)
220221
}
221222

Tests/AWSLambdaEventsTests/SESTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ struct SESTests {
106106
#expect(record.ses.mail.headers[0].value == "<[email protected]>")
107107
#expect(record.ses.mail.headers[1].name == "Received")
108108
#expect(
109-
record.ses.mail.headers[1].value ==
110-
"from mailer.example.com (mailer.example.com [203.0.113.1]) by inbound-smtp.eu-west-1.amazonaws.com with SMTP id o3vrnil0e2ic28trm7dfhrc2v0cnbeccl4nbp0g1 for [email protected]; Wed, 07 Oct 2015 12:34:56 +0000 (UTC)"
109+
record.ses.mail.headers[1].value
110+
== "from mailer.example.com (mailer.example.com [203.0.113.1]) by inbound-smtp.eu-west-1.amazonaws.com with SMTP id o3vrnil0e2ic28trm7dfhrc2v0cnbeccl4nbp0g1 for [email protected]; Wed, 07 Oct 2015 12:34:56 +0000 (UTC)"
111111
)
112112
#expect(record.ses.mail.headersTruncated == true)
113113
#expect(record.ses.mail.messageId == "5h5auqp1oa1bg49b2q8f8tmli1oju8pcma2haao1")

Tests/AWSLambdaEventsTests/SNSTests.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ struct SNSTests {
6565
#expect(record.eventSource == "aws:sns")
6666
#expect(record.eventVersion == "1.0")
6767
#expect(
68-
record.eventSubscriptionArn == "arn:aws:sns:eu-central-1:079477498937:EventSources-SNSTopic-1NHENSE2MQKF5:6fabdb7f-b27e-456d-8e8a-14679db9e40c"
68+
record.eventSubscriptionArn
69+
== "arn:aws:sns:eu-central-1:079477498937:EventSources-SNSTopic-1NHENSE2MQKF5:6fabdb7f-b27e-456d-8e8a-14679db9e40c"
6970
)
7071

7172
#expect(record.sns.type == "Notification")
@@ -75,13 +76,16 @@ struct SNSTests {
7576
#expect(abs(record.sns.timestamp.timeIntervalSince1970 - 1_578_493_131.203) < 0.001)
7677
#expect(record.sns.signatureVersion == "1")
7778
#expect(
78-
record.sns.signature == "LJMF/xmMH7A1gNy2unLA3hmzyf6Be+zS/Yeiiz9tZbu6OG8fwvWZeNOcEZardhSiIStc0TF7h9I+4Qz3omCntaEfayzTGmWN8itGkn2mfn/hMFmPbGM8gEUz3+jp1n6p+iqP3XTx92R0LBIFrU3ylOxSo8+SCOjA015M93wfZzwj0WPtynji9iAvvtf15d8JxPUu1T05BRitpFd5s6ZXDHtVQ4x/mUoLUN8lOVp+rs281/ZdYNUG/V5CwlyUDTOERdryTkBJ/GO1NNPa+6m04ywJFa5d+BC8mDcUcHhhXXjpTEbt8AHBmswK3nudHrVMRO/G4zmssxU2P7ii5+gCfA=="
79+
record.sns.signature
80+
== "LJMF/xmMH7A1gNy2unLA3hmzyf6Be+zS/Yeiiz9tZbu6OG8fwvWZeNOcEZardhSiIStc0TF7h9I+4Qz3omCntaEfayzTGmWN8itGkn2mfn/hMFmPbGM8gEUz3+jp1n6p+iqP3XTx92R0LBIFrU3ylOxSo8+SCOjA015M93wfZzwj0WPtynji9iAvvtf15d8JxPUu1T05BRitpFd5s6ZXDHtVQ4x/mUoLUN8lOVp+rs281/ZdYNUG/V5CwlyUDTOERdryTkBJ/GO1NNPa+6m04ywJFa5d+BC8mDcUcHhhXXjpTEbt8AHBmswK3nudHrVMRO/G4zmssxU2P7ii5+gCfA=="
7981
)
8082
#expect(
81-
record.sns.signingCertURL == "https://sns.eu-central-1.amazonaws.com/SimpleNotificationService-6aad65c2f9911b05cd53efda11f913f9.pem"
83+
record.sns.signingCertURL
84+
== "https://sns.eu-central-1.amazonaws.com/SimpleNotificationService-6aad65c2f9911b05cd53efda11f913f9.pem"
8285
)
8386
#expect(
84-
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"
87+
record.sns.unsubscribeURL
88+
== "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"
8589
)
8690

8791
#expect(record.sns.messageAttributes?.count == 2)

Tests/AWSLambdaEventsTests/Utils/Base64Tests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414

1515
import Testing
1616

17+
@testable import AWSLambdaEvents
18+
1719
#if canImport(FoundationEssentials)
1820
import FoundationEssentials
1921
#else
2022
import Foundation
2123
#endif
2224

23-
@testable import AWSLambdaEvents
24-
2525
@Suite
2626
struct Base64Tests {
2727
// MARK: - Decoding -
2828

2929
@Test func decodeEmptyString() throws {
30-
let decoded = try "".base64decoded()
30+
let decoded = try "".base64decoded()
3131
#expect(decoded.count == 0)
3232
}
3333

@@ -58,14 +58,14 @@ struct Base64Tests {
5858
}
5959

6060
@Test func base64DecodingWithPoop() {
61-
#expect(throws: (any Error).self) {
62-
try "💩".base64decoded()
61+
#expect(throws: (any Error).self) {
62+
try "💩".base64decoded()
6363
}
6464
}
6565

6666
@Test func base64DecodingWithInvalidLength() {
67-
#expect(throws: (any Error).self) {
68-
try "AAAAA".base64decoded()
67+
#expect(throws: (any Error).self) {
68+
try "AAAAA".base64decoded()
6969
}
7070
}
7171

Tests/AWSLambdaEventsTests/Utils/DateWrapperTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct DateWrapperTests {
3939

4040
let date = "2020-03-26T16:53:05" // missing Z at end
4141
let json = #"{"date":"\#(date)"}"#
42-
#expect(throws: (any Error).self) {
42+
#expect(throws: (any Error).self) {
4343
try JSONDecoder().decode(TestEvent.self, from: json.data(using: .utf8)!)
4444
}
4545
}
@@ -64,7 +64,7 @@ struct DateWrapperTests {
6464

6565
let date = "2020-03-26T16:53:05Z" // missing fractional seconds
6666
let json = #"{"date":"\#(date)"}"#
67-
#expect(throws: (any Error).self) {
67+
#expect(throws: (any Error).self) {
6868
try JSONDecoder().decode(TestEvent.self, from: json.data(using: .utf8)!)
6969
}
7070
}
@@ -125,7 +125,7 @@ struct DateWrapperTests {
125125

126126
let date = "Thu, 5 Apr 2012 23:47 +0200" // missing seconds
127127
let json = #"{"date":"\#(date)"}"#
128-
#expect(throws: (any Error).self) {
128+
#expect(throws: (any Error).self) {
129129
try JSONDecoder().decode(TestEvent.self, from: json.data(using: .utf8)!)
130130
}
131131
}

Tests/AWSLambdaEventsTests/Utils/RFC5322DateParseStrategyTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
import Testing
16+
17+
@testable import AWSLambdaEvents
18+
1519
#if canImport(FoundationEssentials)
1620
import FoundationEssentials
1721
#else
1822
import Foundation
1923
#endif
2024

21-
import Testing
22-
23-
@testable import AWSLambdaEvents
24-
2525
@Suite
2626
struct RFC5322DateParseStrategyTests {
2727
let strategy = RFC5322DateParseStrategy(calendar: Calendar(identifier: .gregorian))

0 commit comments

Comments
 (0)