Skip to content

Commit

Permalink
Add APNS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fpseverino committed Aug 9, 2024
1 parent f2d3f02 commit 755ff55
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Tests/OrdersTests/OrdersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ final class OrdersTests: XCTestCase {
try req.content.encode(RegistrationDTO(pushToken: pushToken))
},
afterResponse: { res async throws in
XCTAssertNotEqual(res.status, .unauthorized)
XCTAssertEqual(res.status, .created)
}
)
Expand All @@ -57,6 +58,7 @@ final class OrdersTests: XCTestCase {
try req.content.encode(RegistrationDTO(pushToken: pushToken))
},
afterResponse: { res async throws in
XCTAssertNotEqual(res.status, .unauthorized)
XCTAssertEqual(res.status, .ok)
}
)
Expand Down Expand Up @@ -91,6 +93,7 @@ final class OrdersTests: XCTestCase {
"\(ordersURI)devices/\(deviceLibraryIdentifier)/registrations/\(order.orderTypeIdentifier)/\(order.requireID())",
headers: ["Authorization": "AppleOrder \(order.authenticationToken)"],
afterResponse: { res async throws in
XCTAssertNotEqual(res.status, .unauthorized)
XCTAssertEqual(res.status, .ok)
}
)
Expand All @@ -116,4 +119,12 @@ final class OrdersTests: XCTestCase {
XCTAssertEqual(logs[0].message, log1)
XCTAssertEqual(logs[1].message, log2)
}

func testAPNSClient() async throws {
XCTAssertNotNil(app.apns.client(.init(string: "orders")))
let orderData = OrderData(title: "Test Order")
try await orderData.create(on: app.db)
let order = try await orderData.$order.get(on: app.db)
try await ordersService.sendPushNotifications(for: order, on: app.db)
}
}
11 changes: 11 additions & 0 deletions Tests/PassesTests/PassesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ final class PassesTests: XCTestCase {
try req.content.encode(RegistrationDTO(pushToken: pushToken))
},
afterResponse: { res async throws in
XCTAssertNotEqual(res.status, .unauthorized)
XCTAssertEqual(res.status, .created)
}
)
Expand All @@ -84,6 +85,7 @@ final class PassesTests: XCTestCase {
try req.content.encode(RegistrationDTO(pushToken: pushToken))
},
afterResponse: { res async throws in
XCTAssertNotEqual(res.status, .unauthorized)
XCTAssertEqual(res.status, .ok)
}
)
Expand Down Expand Up @@ -116,6 +118,7 @@ final class PassesTests: XCTestCase {
"\(passesURI)devices/\(deviceLibraryIdentifier)/registrations/\(pass.passTypeIdentifier)/\(pass.requireID())",
headers: ["Authorization": "ApplePass \(pass.authenticationToken)"],
afterResponse: { res async throws in
XCTAssertNotEqual(res.status, .unauthorized)
XCTAssertEqual(res.status, .ok)
}
)
Expand All @@ -141,4 +144,12 @@ final class PassesTests: XCTestCase {
XCTAssertEqual(logs[0].message, log1)
XCTAssertEqual(logs[1].message, log2)
}

func testAPNSClient() async throws {
XCTAssertNotNil(app.apns.client(.init(string: "passes")))
let passData = PassData(title: "Test Pass")
try await passData.create(on: app.db)
let pass = try await passData.$pass.get(on: app.db)
try await passesService.sendPushNotifications(for: pass, on: app.db)
}
}

0 comments on commit 755ff55

Please sign in to comment.