Skip to content

Commit 157d520

Browse files
committed
Swift 6
1 parent 03e9087 commit 157d520

File tree

8 files changed

+169
-165
lines changed

8 files changed

+169
-165
lines changed

.github/workflows/api-breakage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
timeout-minutes: 15
1313
container:
14-
image: swift:5.10
14+
image: swift:latest
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v4

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
strategy:
2525
matrix:
2626
image:
27-
- 'swift:5.10'
27+
- 'swift:latest'
2828
container:
2929
image: ${{ matrix.image }}
3030
steps:

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ jobs:
4040
strategy:
4141
matrix:
4242
image:
43-
- 'swift:5.8'
4443
- 'swift:5.9'
4544
- 'swift:5.10'
46-
- 'swiftlang/swift:nightly-jammy'
45+
- 'swift:6.0'
4746
container:
4847
image: ${{ matrix.image }}
4948
steps:

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.8
1+
// swift-tools-version:5.9
22
//===----------------------------------------------------------------------===//
33
//
44
// This source file is part of the Soto for AWS open source project

Sources/SotoCore/HTTP/AWSHTTPBody.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public struct AWSHTTPBody: Sendable {
5151
self.storage = .asyncSequence(sequence: .init(asyncSequence), length: length)
5252
}
5353

54+
public init<BufferSequence: AsyncSequence & Sendable>(asyncSequence: BufferSequence, length: Int?) where BufferSequence.Element: Collection<UInt8> & Sendable {
55+
self.storage = .asyncSequence(sequence: .init(asyncSequence.map { .init(bytes: $0) }), length: length)
56+
}
57+
5458
public func collect(upTo length: Int) async throws -> ByteBuffer {
5559
switch self.storage {
5660
case .byteBuffer(let buffer):

Sources/SotoTestUtils/TestUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,4 @@ public func withTeardown<Value>(_ process: () async throws -> Value, teardown: (
141141
}
142142
await teardown()
143143
return result
144-
}
144+
}

Tests/SotoCoreTests/AWSClientTests.swift

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -52,42 +52,43 @@ class AWSClientTests: XCTestCase {
5252
let awsServer = AWSTestServer(serviceProtocol: .json)
5353
let elg = MultiThreadedEventLoopGroup(numberOfThreads: 1)
5454
let httpClient = HTTPClient(eventLoopGroupProvider: .shared(elg))
55-
defer {
55+
try await withTeardown {
56+
let config = createServiceConfig(
57+
serviceProtocol: .json(version: "1.1"),
58+
endpoint: awsServer.address
59+
)
60+
let client = createAWSClient(
61+
credentialProvider: .static(accessKeyId: "foo", secretAccessKey: "bar"),
62+
httpClient: httpClient
63+
)
64+
defer {
65+
XCTAssertNoThrow(try client.syncShutdown())
66+
}
67+
async let responseTask: AWSTestServer.HTTPBinResponse = client.execute(
68+
operation: "test",
69+
path: "/",
70+
httpMethod: .POST,
71+
serviceConfig: config,
72+
input: Input(content: "test"),
73+
logger: TestEnvironment.logger
74+
)
75+
76+
XCTAssertNoThrow(try awsServer.httpBin())
77+
78+
let httpBinResponse = try await responseTask
79+
let httpHeaders = HTTPHeaders(httpBinResponse.headers.map { ($0, $1) })
80+
81+
XCTAssertEqual(httpHeaders["content-length"].first, "18")
82+
XCTAssertEqual(httpHeaders["content-type"].first, "application/x-amz-json-1.1")
83+
XCTAssertNotNil(httpHeaders["authorization"].first)
84+
XCTAssertNotNil(httpHeaders["x-amz-date"].first)
85+
XCTAssertEqual(httpHeaders["user-agent"].first, "Soto/6.0")
86+
XCTAssertEqual(httpHeaders["host"].first, "localhost:\(awsServer.serverPort)")
87+
} teardown: {
5688
try? awsServer.stop()
57-
try? httpClient.syncShutdown()
58-
try? elg.syncShutdownGracefully()
59-
}
60-
let config = createServiceConfig(
61-
serviceProtocol: .json(version: "1.1"),
62-
endpoint: awsServer.address
63-
)
64-
let client = createAWSClient(
65-
credentialProvider: .static(accessKeyId: "foo", secretAccessKey: "bar"),
66-
httpClient: httpClient
67-
)
68-
defer {
69-
XCTAssertNoThrow(try client.syncShutdown())
89+
try? await httpClient.shutdown()
90+
try? await elg.shutdownGracefully()
7091
}
71-
async let responseTask: AWSTestServer.HTTPBinResponse = client.execute(
72-
operation: "test",
73-
path: "/",
74-
httpMethod: .POST,
75-
serviceConfig: config,
76-
input: Input(content: "test"),
77-
logger: TestEnvironment.logger
78-
)
79-
80-
XCTAssertNoThrow(try awsServer.httpBin())
81-
82-
let httpBinResponse = try await responseTask
83-
let httpHeaders = HTTPHeaders(httpBinResponse.headers.map { ($0, $1) })
84-
85-
XCTAssertEqual(httpHeaders["content-length"].first, "18")
86-
XCTAssertEqual(httpHeaders["content-type"].first, "application/x-amz-json-1.1")
87-
XCTAssertNotNil(httpHeaders["authorization"].first)
88-
XCTAssertNotNil(httpHeaders["x-amz-date"].first)
89-
XCTAssertEqual(httpHeaders["user-agent"].first, "Soto/6.0")
90-
XCTAssertEqual(httpHeaders["host"].first, "localhost:\(awsServer.serverPort)")
9192
}
9293

9394
func testClientNoInputNoOutput() async throws {

0 commit comments

Comments
 (0)