Skip to content

Commit d8ffed6

Browse files
committed
swift-format
1 parent 8f651e8 commit d8ffed6

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed

Sources/AWSLambdaRuntime/LambdaContext.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ public struct ClientApplication: Codable, Sendable {
3030
public let appVersionCode: String?
3131
/// The package name for the mobile application invoking the function
3232
public let appPackageName: String?
33-
33+
3434
private enum CodingKeys: String, CodingKey {
3535
case installationId = "installation_id"
3636
case appTitle = "app_title"
3737
case appVersionName = "app_version_name"
3838
case appVersionCode = "app_version_code"
3939
case appPackageName = "app_package_name"
4040
}
41-
41+
4242
public init(
4343
installationId: String? = nil,
4444
appTitle: String? = nil,
@@ -62,13 +62,13 @@ public struct ClientContext: Codable, Sendable {
6262
public let custom: [String: String]?
6363
/// Environment settings from the mobile client.
6464
public let environment: [String: String]?
65-
65+
6666
private enum CodingKeys: String, CodingKey {
6767
case client
6868
case custom
6969
case environment = "env"
7070
}
71-
71+
7272
public init(
7373
client: ClientApplication? = nil,
7474
custom: [String: String]? = nil,

Tests/AWSLambdaRuntimeTests/LambdaContextTests.swift

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

15+
import Foundation
1516
import Testing
17+
1618
@testable import AWSLambdaRuntime
17-
import Foundation
1819

1920
@Suite("LambdaContext ClientContext Tests")
2021
struct LambdaContextTests {
21-
22+
2223
@Test("ClientContext with full data resolves correctly")
2324
func clientContextWithFullDataResolves() throws {
2425
let custom = ["key": "value"]
@@ -34,17 +35,17 @@ struct LambdaContextTests {
3435
custom: custom,
3536
environment: environment
3637
)
37-
38+
3839
let encoder = JSONEncoder()
3940
let clientContextData = try encoder.encode(clientContext)
40-
41+
4142
// Verify JSON encoding/decoding works correctly
4243
let decoder = JSONDecoder()
4344
let decodedClientContext = try decoder.decode(ClientContext.self, from: clientContextData)
44-
45+
4546
let decodedClient = try #require(decodedClientContext.client)
4647
let originalClient = try #require(clientContext.client)
47-
48+
4849
#expect(decodedClient.installationId == originalClient.installationId)
4950
#expect(decodedClient.appTitle == originalClient.appTitle)
5051
#expect(decodedClient.appVersionName == originalClient.appVersionName)
@@ -53,61 +54,61 @@ struct LambdaContextTests {
5354
#expect(decodedClientContext.custom == clientContext.custom)
5455
#expect(decodedClientContext.environment == clientContext.environment)
5556
}
56-
57+
5758
@Test("ClientContext with empty data resolves correctly")
5859
func clientContextWithEmptyDataResolves() throws {
5960
let emptyClientContextJSON = "{}"
6061
let emptyClientContextData = emptyClientContextJSON.data(using: .utf8)!
61-
62+
6263
let decoder = JSONDecoder()
6364
let decodedClientContext = try decoder.decode(ClientContext.self, from: emptyClientContextData)
64-
65+
6566
// With empty JSON, we expect nil values for optional fields
6667
#expect(decodedClientContext.client == nil)
6768
#expect(decodedClientContext.custom == nil)
6869
#expect(decodedClientContext.environment == nil)
6970
}
70-
71+
7172
@Test("ClientContext with AWS Lambda JSON payload decodes correctly")
7273
func clientContextWithAWSLambdaJSONPayload() throws {
7374
let jsonPayload = """
74-
{
75-
"client": {
76-
"installation_id": "example-id",
77-
"app_title": "Example App",
78-
"app_version_name": "1.0",
79-
"app_version_code": "1",
80-
"app_package_name": "com.example.app"
81-
},
82-
"custom": {
83-
"customKey": "customValue"
84-
},
85-
"env": {
86-
"platform": "Android",
87-
"platform_version": "10"
88-
}
89-
}
90-
"""
91-
75+
{
76+
"client": {
77+
"installation_id": "example-id",
78+
"app_title": "Example App",
79+
"app_version_name": "1.0",
80+
"app_version_code": "1",
81+
"app_package_name": "com.example.app"
82+
},
83+
"custom": {
84+
"customKey": "customValue"
85+
},
86+
"env": {
87+
"platform": "Android",
88+
"platform_version": "10"
89+
}
90+
}
91+
"""
92+
9293
let jsonData = jsonPayload.data(using: .utf8)!
9394
let decoder = JSONDecoder()
9495
let decodedClientContext = try decoder.decode(ClientContext.self, from: jsonData)
95-
96+
9697
// Verify client application data
9798
let client = try #require(decodedClientContext.client)
9899
#expect(client.installationId == "example-id")
99100
#expect(client.appTitle == "Example App")
100101
#expect(client.appVersionName == "1.0")
101102
#expect(client.appVersionCode == "1")
102103
#expect(client.appPackageName == "com.example.app")
103-
104+
104105
// Verify custom properties
105106
let custom = try #require(decodedClientContext.custom)
106107
#expect(custom["customKey"] == "customValue")
107-
108+
108109
// Verify environment settings
109110
let environment = try #require(decodedClientContext.environment)
110111
#expect(environment["platform"] == "Android")
111112
#expect(environment["platform_version"] == "10")
112113
}
113-
}
114+
}

0 commit comments

Comments
 (0)