Merge remote-tracking branch 'refs/remotes/origin/main'

online_payment
Raz 7 months ago
commit 4054ada79c
  1. 4
      PadelClub/Data/DataStore.swift
  2. 19
      PadelClubTests/ServerDataTests.swift

@ -246,6 +246,10 @@ class DataStore: ObservableObject {
}
func tryUserUpdate(userCopy: CustomUser) async throws -> CustomUser? {
return try await self.userStorage.tryPutBeforeUpdating(userCopy)
}
// func copyToLocalServer(tournament: Tournament) {
//
// Task {

@ -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)
}
}
}

Loading…
Cancel
Save