Skip to content

Commit 9a46b09

Browse files
committed
Update sessions to swift 6
1 parent f953784 commit 9a46b09

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

sessions/Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.9
1+
// swift-tools-version:6.0
22
import PackageDescription
33

44
let package = Package(
@@ -10,9 +10,9 @@ let package = Package(
1010
.executable(name: "App", targets: ["App"]),
1111
],
1212
dependencies: [
13-
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0"),
13+
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.19.0"),
1414
.package(url: "https://github.com/hummingbird-project/hummingbird-auth.git", from: "2.0.0"),
15-
.package(url: "https://github.com/hummingbird-project/hummingbird-fluent.git", from: "2.0.0-beta.2"),
15+
.package(url: "https://github.com/hummingbird-project/hummingbird-fluent.git", from: "2.0.0"),
1616
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.48.5"),
1717
.package(url: "https://github.com/vapor/fluent-sqlite-driver.git", from: "4.7.0"),
1818
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.4.0"),

sessions/Tests/AppTests/AppTests.swift

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
@testable import App
1+
import Foundation
22
import Hummingbird
33
import HummingbirdAuthTesting
44
import HummingbirdTesting
5-
import XCTest
5+
import Testing
6+
7+
@testable import App
68

79
struct TestArguments: AppArguments {
810
var migrate: Bool = true
911
var inMemoryDatabase: Bool = true
1012
}
1113

12-
final class AppTests: XCTestCase {
14+
struct AppTests {
1315
func createUser<Return>(
1416
name: String,
1517
password: String,
@@ -32,7 +34,7 @@ final class AppTests: XCTestCase {
3234
client: some TestClientProtocol,
3335
_ callback: @escaping (TestResponse) throws -> Return
3436
) async throws -> Return {
35-
return try await client.execute(
37+
try await client.execute(
3638
uri: "/user/login",
3739
method: .post,
3840
auth: .basic(username: name, password: password)
@@ -46,7 +48,7 @@ final class AppTests: XCTestCase {
4648
client: some TestClientProtocol,
4749
_ callback: @escaping (TestResponse) throws -> Return
4850
) async throws -> Return {
49-
return try await client.execute(
51+
try await client.execute(
5052
uri: "/user",
5153
method: .get,
5254
headers: cookie.map { [.cookie: $0] } ?? [:]
@@ -55,48 +57,47 @@ final class AppTests: XCTestCase {
5557
}
5658
}
5759

58-
func testCreateUser() async throws {
60+
@Test func testCreateUser() async throws {
5961
let app = try await buildApplication(TestArguments(), configuration: .init())
6062
try await app.test(.live) { client in
6163
try await self.createUser(name: "adam", password: "test", client: client) { response in
62-
XCTAssertEqual(response.status, .ok)
64+
#expect(response.status == .ok)
6365
}
6466
try await self.createUser(name: "adam", password: "test", client: client) { response in
65-
XCTAssertEqual(response.status, .conflict)
67+
#expect(response.status == .conflict)
6668
}
6769
}
6870
}
6971

70-
func testLogin() async throws {
72+
@Test func testLogin() async throws {
7173
let app = try await buildApplication(TestArguments(), configuration: .init())
7274
try await app.test(.live) { client in
7375
try await self.createUser(name: "adam", password: "testLogin", client: client) { response in
74-
XCTAssertEqual(response.status, .ok)
76+
#expect(response.status == .ok)
7577
}
7678
try await self.login(name: "adam", password: "testLogin", client: client) { response in
77-
XCTAssertEqual(response.status, .ok)
79+
#expect(response.status == .ok)
7880
}
7981
}
8082
}
8183

82-
func testSession() async throws {
84+
@Test func testSession() async throws {
8385
let app = try await buildApplication(TestArguments(), configuration: .init())
8486
try await app.test(.live) { client in
8587
try await self.createUser(name: "john", password: "testSession", client: client) { response in
86-
XCTAssertEqual(response.status, .ok)
88+
#expect(response.status == .ok)
8789
}
8890
let cookie = try await self.login(name: "john", password: "testSession", client: client) { response in
89-
XCTAssertEqual(response.status, .ok)
90-
return try XCTUnwrap(response.headers[.setCookie])
91+
#expect(response.status == .ok)
92+
return try #require(response.headers[.setCookie])
9193
}
9294
try await self.getCurrent(cookie: cookie, client: client) { response in
93-
XCTAssertEqual(response.status, .ok)
94-
let body = try XCTUnwrap(response.body)
95-
let user = try JSONDecoder().decode(UserResponse.self, from: body)
96-
XCTAssertEqual(user.name, "john")
95+
#expect(response.status == .ok)
96+
let user = try JSONDecoder().decode(UserResponse.self, from: response.body)
97+
#expect(user.name == "john")
9798
}
9899
try await self.getCurrent(cookie: nil, client: client) { response in
99-
XCTAssertEqual(response.status, .unauthorized)
100+
#expect(response.status == .unauthorized)
100101
}
101102
}
102103
}

0 commit comments

Comments
 (0)