Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fpseverino committed Sep 25, 2024
1 parent 6924e03 commit 7da8f36
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Tests/OrdersTests/OrdersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,39 @@ final class OrdersTests: XCTestCase {
}
)

// Test registration of a non-existing order
try await app.test(
.POST,
"\(ordersURI)devices/\(deviceLibraryIdentifier)/registrations/\("order.com.example.NotFound")/\(UUID().uuidString)",
headers: ["Authorization": "AppleOrder \(order.authenticationToken)"],
beforeRequest: { req async throws in
try req.content.encode(RegistrationDTO(pushToken: pushToken))
},
afterResponse: { res async throws in
XCTAssertEqual(res.status, .notFound)
}
)

// Test call without DTO
try await app.test(
.POST,
"\(ordersURI)devices/\(deviceLibraryIdentifier)/registrations/\(order.orderTypeIdentifier)/\(order.requireID())",
headers: ["Authorization": "AppleOrder \(order.authenticationToken)"],
afterResponse: { res async throws in
XCTAssertEqual(res.status, .badRequest)
}
)

// Test call with invalid UUID
try await app.test(
.POST,
"\(ordersURI)devices/\(deviceLibraryIdentifier)/registrations/\(order.orderTypeIdentifier)/\("not-a-uuid")",
headers: ["Authorization": "AppleOrder \(order.authenticationToken)"],
afterResponse: { res async throws in
XCTAssertEqual(res.status, .badRequest)
}
)

try await app.test(
.POST,
"\(ordersURI)devices/\(deviceLibraryIdentifier)/registrations/\(order.orderTypeIdentifier)/\(order.requireID())",
Expand Down Expand Up @@ -205,6 +238,7 @@ final class OrdersTests: XCTestCase {
}
)

// Test call with invalid UUID
try await app.test(
.GET,
"\(ordersURI)push/\(order.orderTypeIdentifier)/\("not-a-uuid")",
Expand Down Expand Up @@ -309,6 +343,7 @@ final class OrdersTests: XCTestCase {
}
)

// Test call with invalid UUID
try await app.test(
.POST,
"\(ordersURI)push/\(order.orderTypeIdentifier)/\("not-a-uuid")",
Expand Down
35 changes: 35 additions & 0 deletions Tests/PassesTests/PassesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,39 @@ final class PassesTests: XCTestCase {
}
)

// Test registration of a non-existing pass
try await app.test(
.POST,
"\(passesURI)devices/\(deviceLibraryIdentifier)/registrations/\("pass.com.example.NotFound")/\(UUID().uuidString)",
headers: ["Authorization": "ApplePass \(pass.authenticationToken)"],
beforeRequest: { req async throws in
try req.content.encode(RegistrationDTO(pushToken: pushToken))
},
afterResponse: { res async throws in
XCTAssertEqual(res.status, .notFound)
}
)

// Test call without DTO
try await app.test(
.POST,
"\(passesURI)devices/\(deviceLibraryIdentifier)/registrations/\(pass.passTypeIdentifier)/\(pass.requireID())",
headers: ["Authorization": "ApplePass \(pass.authenticationToken)"],
afterResponse: { res async throws in
XCTAssertEqual(res.status, .badRequest)
}
)

// Test call with invalid UUID
try await app.test(
.POST,
"\(passesURI)devices/\(deviceLibraryIdentifier)/registrations/\(pass.passTypeIdentifier)/\("not-a-uuid")",
headers: ["Authorization": "ApplePass \(pass.authenticationToken)"],
afterResponse: { res async throws in
XCTAssertEqual(res.status, .badRequest)
}
)

try await app.test(
.POST,
"\(passesURI)devices/\(deviceLibraryIdentifier)/registrations/\(pass.passTypeIdentifier)/\(pass.requireID())",
Expand Down Expand Up @@ -343,6 +376,7 @@ final class PassesTests: XCTestCase {
}
)

// Test call with invalid UUID
try await app.test(
.GET,
"\(passesURI)push/\(pass.passTypeIdentifier)/\("not-a-uuid")",
Expand Down Expand Up @@ -447,6 +481,7 @@ final class PassesTests: XCTestCase {
}
)

// Test call with invalid UUID
try await app.test(
.POST,
"\(passesURI)push/\(pass.passTypeIdentifier)/\("not-a-uuid")",
Expand Down

0 comments on commit 7da8f36

Please sign in to comment.