|
|
|
|
@ -435,7 +435,7 @@ final class ServerDataTests: XCTestCase { |
|
|
|
|
let transactionId = UInt64.random(in: 0...100000) |
|
|
|
|
let quantity = Int.random(in: 0...10) |
|
|
|
|
|
|
|
|
|
let purchase: Purchase = Purchase(user: userId, transactionId: transactionId, purchaseDate: Date(), productId: "app.padelclub.productId", quantity: quantity, revocationDate: Date(), expirationDate: Date()) |
|
|
|
|
let purchase: Purchase = Purchase(transactionId: transactionId, user: userId, purchaseDate: Date(), productId: "app.padelclub.productId", quantity: quantity, revocationDate: Date(), expirationDate: Date()) |
|
|
|
|
|
|
|
|
|
if let p: Purchase = try await StoreCenter.main.service().post(purchase) { |
|
|
|
|
|
|
|
|
|
@ -476,4 +476,21 @@ final class ServerDataTests: XCTestCase { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// needs a user with the licenceId set to "5186803D" to suceed |
|
|
|
|
func testTryPutBeforeUpdating() async throws { |
|
|
|
|
|
|
|
|
|
let service = try StoreCenter.main.service() |
|
|
|
|
let user: CustomUser = try await service.login(username: self.username, password: self.password) |
|
|
|
|
|
|
|
|
|
let copy: CustomUser = user.copy() |
|
|
|
|
copy.licenceId = "5186803D" |
|
|
|
|
do { |
|
|
|
|
_ = try await DataStore.shared.tryUserUpdate(userCopy: copy) |
|
|
|
|
XCTFail("should fail because licenceId is the same than dummy's") |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|