Skip to content

Commit 593adcc

Browse files
committed
swift format
1 parent eb4e376 commit 593adcc

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

[email protected]

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ let package = Package(
6161
.define("FoundationJSONSupport"),
6262
.define("ServiceLifecycleSupport"),
6363
.define("LocalServerSupport"),
64-
]
64+
]
6565
),
6666
// for perf testing
6767
.executableTarget(
+26-25
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,51 @@
11
import Testing
2+
23
@testable import AWSLambdaRuntime
34

45
struct PoolTests {
5-
6+
67
@Test
78
func testBasicPushAndIteration() async throws {
89
let pool = LambdaHTTPServer.Pool<String>()
9-
10+
1011
// Push values
1112
await pool.push("first")
1213
await pool.push("second")
13-
14+
1415
// Iterate and verify order
1516
var values = [String]()
1617
for try await value in pool {
1718
values.append(value)
1819
if values.count == 2 { break }
1920
}
20-
21+
2122
#expect(values == ["first", "second"])
2223
}
23-
24+
2425
@Test
2526
func testCancellation() async throws {
2627
let pool = LambdaHTTPServer.Pool<String>()
27-
28+
2829
// Create a task that will be cancelled
2930
let task = Task {
3031
for try await _ in pool {
3132
Issue.record("Should not receive any values after cancellation")
3233
}
3334
}
34-
35+
3536
// Cancel the task immediately
3637
task.cancel()
37-
38+
3839
// This should complete without receiving any values
3940
try await task.value
4041
}
41-
42+
4243
@Test
4344
func testConcurrentPushAndIteration() async throws {
4445
let pool = LambdaHTTPServer.Pool<Int>()
4546
let iterations = 1000
4647
var receivedValues = Set<Int>()
47-
48+
4849
// Start consumer task first
4950
let consumer = Task {
5051
var count = 0
@@ -54,7 +55,7 @@ struct PoolTests {
5455
if count >= iterations { break }
5556
}
5657
}
57-
58+
5859
// Create multiple producer tasks
5960
try await withThrowingTaskGroup(of: Void.self) { group in
6061
for i in 0..<iterations {
@@ -64,45 +65,45 @@ struct PoolTests {
6465
}
6566
try await group.waitForAll()
6667
}
67-
68+
6869
// Wait for consumer to complete
6970
try await consumer.value
70-
71+
7172
// Verify all values were received exactly once
7273
#expect(receivedValues.count == iterations)
7374
#expect(Set(0..<iterations) == receivedValues)
7475
}
75-
76+
7677
@Test
7778
func testPushToWaitingConsumer() async throws {
7879
let pool = LambdaHTTPServer.Pool<String>()
7980
let expectedValue = "test value"
80-
81+
8182
// Start a consumer that will wait for a value
8283
let consumer = Task {
8384
for try await value in pool {
8485
#expect(value == expectedValue)
8586
break
8687
}
8788
}
88-
89+
8990
// Give consumer time to start waiting
90-
try await Task.sleep(nanoseconds: 100_000_000) // 0.1 seconds
91-
91+
try await Task.sleep(nanoseconds: 100_000_000) // 0.1 seconds
92+
9293
// Push a value
9394
await pool.push(expectedValue)
94-
95+
9596
// Wait for consumer to complete
9697
try await consumer.value
9798
}
98-
99+
99100
@Test
100101
func testStressTest() async throws {
101102
let pool = LambdaHTTPServer.Pool<Int>()
102103
let producerCount = 10
103104
let messagesPerProducer = 1000
104105
var receivedValues = [Int]()
105-
106+
106107
// Start consumer
107108
let consumer = Task {
108109
var count = 0
@@ -112,7 +113,7 @@ struct PoolTests {
112113
if count >= producerCount * messagesPerProducer { break }
113114
}
114115
}
115-
116+
116117
// Create multiple producers
117118
try await withThrowingTaskGroup(of: Void.self) { group in
118119
for p in 0..<producerCount {
@@ -124,12 +125,12 @@ struct PoolTests {
124125
}
125126
try await group.waitForAll()
126127
}
127-
128+
128129
// Wait for consumer to complete
129130
try await consumer.value
130-
131+
131132
// Verify we received all values
132133
#expect(receivedValues.count == producerCount * messagesPerProducer)
133134
#expect(Set(receivedValues).count == producerCount * messagesPerProducer)
134135
}
135-
}
136+
}

0 commit comments

Comments
 (0)