Skip to content

Commit

Permalink
Add even more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fpseverino committed Sep 25, 2024
1 parent 7da8f36 commit 8926051
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Tests/OrdersTests/OrdersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ final class OrdersTests: XCTestCase {
let deviceLibraryIdentifier = "abcdefg"
let pushToken = "1234567890"

try await app.test(
.GET,
"\(ordersURI)devices/\(deviceLibraryIdentifier)/registrations/\(order.orderTypeIdentifier)?ordersModifiedSince=0",
afterResponse: { res async throws in
XCTAssertEqual(res.status, .noContent)
}
)

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

// Test registration without authentication token
try await app.test(
.POST,
Expand Down Expand Up @@ -248,6 +265,16 @@ final class OrdersTests: XCTestCase {
}
)

// Test call with invalid UUID
try await app.test(
.DELETE,
"\(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(
.DELETE,
"\(ordersURI)devices/\(deviceLibraryIdentifier)/registrations/\(order.orderTypeIdentifier)/\(order.requireID())",
Expand Down
27 changes: 27 additions & 0 deletions Tests/PassesTests/PassesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,23 @@ final class PassesTests: XCTestCase {
let deviceLibraryIdentifier = "abcdefg"
let pushToken = "1234567890"

try await app.test(
.GET,
"\(passesURI)devices/\(deviceLibraryIdentifier)/registrations/\(pass.passTypeIdentifier)?passesUpdatedSince=0",
afterResponse: { res async throws in
XCTAssertEqual(res.status, .noContent)
}
)

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

// Test registration without authentication token
try await app.test(
.POST,
Expand Down Expand Up @@ -386,6 +403,16 @@ final class PassesTests: XCTestCase {
}
)

// Test call with invalid UUID
try await app.test(
.DELETE,
"\(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(
.DELETE,
"\(passesURI)devices/\(deviceLibraryIdentifier)/registrations/\(pass.passTypeIdentifier)/\(pass.requireID())",
Expand Down

0 comments on commit 8926051

Please sign in to comment.