@ -31,7 +31,7 @@ final class ServerDataTests: XCTestCase {
func login ( ) async throws {
func login ( ) async throws {
// p r i n t ( " L O G I N ! " )
// p r i n t ( " L O G I N ! " )
let _ : User = try await StoreCenter . main . service ( ) . login ( username : self . username , password : self . password )
let _ : Custom User = try await StoreCenter . main . service ( ) . login ( username : self . username , password : self . password )
}
}
func testClub ( ) async throws {
func testClub ( ) async throws {
@ -48,6 +48,7 @@ final class ServerDataTests: XCTestCase {
club . courtCount = 3
club . courtCount = 3
let inserted_club : Club = try await StoreCenter . main . service ( ) . post ( club )
let inserted_club : Club = try await StoreCenter . main . service ( ) . post ( club )
assert ( inserted_club . lastUpdate = = club . lastUpdate )
assert ( inserted_club . name = = club . name )
assert ( inserted_club . name = = club . name )
assert ( inserted_club . acronym = = club . acronym )
assert ( inserted_club . acronym = = club . acronym )
assert ( inserted_club . zipCode = = club . zipCode )
assert ( inserted_club . zipCode = = club . zipCode )
@ -59,6 +60,7 @@ final class ServerDataTests: XCTestCase {
assert ( inserted_club . broadcastCode != nil )
assert ( inserted_club . broadcastCode != nil )
inserted_club . phone = " 123456 "
inserted_club . phone = " 123456 "
inserted_club . lastUpdate = Date ( )
let updated_club : Club = try await StoreCenter . main . service ( ) . put ( inserted_club )
let updated_club : Club = try await StoreCenter . main . service ( ) . put ( inserted_club )
assert ( updated_club . phone = = inserted_club . phone )
assert ( updated_club . phone = = inserted_club . phone )
@ -66,7 +68,7 @@ final class ServerDataTests: XCTestCase {
}
}
func testLogin ( ) async throws {
func testLogin ( ) async throws {
let user : User = try await StoreCenter . main . service ( ) . login ( username : self . username , password : self . password )
let user : Custom User = try await StoreCenter . main . service ( ) . login ( username : self . username , password : self . password )
assert ( user . username = = " test " )
assert ( user . username = = " test " )
}
}
@ -87,6 +89,7 @@ final class ServerDataTests: XCTestCase {
let e = try await StoreCenter . main . service ( ) . post ( event )
let e = try await StoreCenter . main . service ( ) . post ( event )
assert ( e . name = = event . name )
assert ( e . name = = event . name )
assert ( e . lastUpdate = = event . lastUpdate )
assert ( e . tenupId = = event . tenupId )
assert ( e . tenupId = = event . tenupId )
}
}
@ -102,6 +105,7 @@ final class ServerDataTests: XCTestCase {
let tournament = Tournament ( event : eventId , name : " RG Homme " , startDate : Date ( ) , endDate : nil , creationDate : Date ( ) , isPrivate : false , groupStageFormat : MatchFormat . megaTie , roundFormat : MatchFormat . nineGames , loserRoundFormat : MatchFormat . nineGamesDecisivePoint , groupStageSortMode : GroupStageOrderingMode . snake , groupStageCount : 2 , rankSourceDate : Date ( ) , dayDuration : 5 , teamCount : 3 , teamSorting : TeamSortingType . rank , federalCategory : TournamentCategory . mix , federalLevelCategory : TournamentLevel . p1000 , federalAgeCategory : FederalTournamentAge . a45 , closedRegistrationDate : Date ( ) , groupStageAdditionalQualified : 4 , courtCount : 9 , prioritizeClubMembers : true , qualifiedPerGroupStage : 1 , teamsPerGroupStage : 2 , entryFee : 30.0 , additionalEstimationDuration : 5 , isDeleted : true , publishTeams : true , publishSummons : true , publishGroupStages : true , publishBrackets : true , shouldVerifyBracket : true , shouldVerifyGroupStage : true , hideTeamsWeight : true , publishTournament : true , hidePointsEarned : true , publishRankings : true , loserBracketMode : . manual )
let tournament = Tournament ( event : eventId , name : " RG Homme " , startDate : Date ( ) , endDate : nil , creationDate : Date ( ) , isPrivate : false , groupStageFormat : MatchFormat . megaTie , roundFormat : MatchFormat . nineGames , loserRoundFormat : MatchFormat . nineGamesDecisivePoint , groupStageSortMode : GroupStageOrderingMode . snake , groupStageCount : 2 , rankSourceDate : Date ( ) , dayDuration : 5 , teamCount : 3 , teamSorting : TeamSortingType . rank , federalCategory : TournamentCategory . mix , federalLevelCategory : TournamentLevel . p1000 , federalAgeCategory : FederalTournamentAge . a45 , closedRegistrationDate : Date ( ) , groupStageAdditionalQualified : 4 , courtCount : 9 , prioritizeClubMembers : true , qualifiedPerGroupStage : 1 , teamsPerGroupStage : 2 , entryFee : 30.0 , additionalEstimationDuration : 5 , isDeleted : true , publishTeams : true , publishSummons : true , publishGroupStages : true , publishBrackets : true , shouldVerifyBracket : true , shouldVerifyGroupStage : true , hideTeamsWeight : true , publishTournament : true , hidePointsEarned : true , publishRankings : true , loserBracketMode : . manual )
let t = try await StoreCenter . main . service ( ) . post ( tournament )
let t = try await StoreCenter . main . service ( ) . post ( tournament )
assert ( t . lastUpdate . formatted ( ) = = tournament . lastUpdate . formatted ( ) )
assert ( t . event = = tournament . event )
assert ( t . event = = tournament . event )
assert ( t . name = = tournament . name )
assert ( t . name = = tournament . name )
assert ( t . startDate . formatted ( ) = = tournament . startDate . formatted ( ) )
assert ( t . startDate . formatted ( ) = = tournament . startDate . formatted ( ) )
@ -151,9 +155,12 @@ final class ServerDataTests: XCTestCase {
}
}
let groupStage = GroupStage ( tournament : tournamentId , index : 2 , size : 3 , matchFormat : MatchFormat . nineGames , startDate : Date ( ) , name : " Yeah! " , step : 1 )
let groupStage = GroupStage ( tournament : tournamentId , index : 2 , size : 3 , matchFormat : MatchFormat . nineGames , startDate : Date ( ) , name : " Yeah! " , step : 1 )
groupStage . storeId = " 123 "
let gs : GroupStage = try await StoreCenter . main . service ( ) . post ( groupStage )
let gs : GroupStage = try await StoreCenter . main . service ( ) . post ( groupStage )
assert ( gs . tournament = = groupStage . tournament )
assert ( gs . tournament = = groupStage . tournament )
assert ( gs . storeId = = groupStage . storeId )
assert ( gs . lastUpdate = = groupStage . lastUpdate )
assert ( gs . name = = groupStage . name )
assert ( gs . name = = groupStage . name )
assert ( gs . index = = groupStage . index )
assert ( gs . index = = groupStage . index )
assert ( gs . size = = groupStage . size )
assert ( gs . size = = groupStage . size )
@ -175,9 +182,12 @@ final class ServerDataTests: XCTestCase {
let parentRoundId = rounds . first ? . id
let parentRoundId = rounds . first ? . id
let round = Round ( tournament : tournamentId , index : 1 , parent : parentRoundId , matchFormat : MatchFormat . nineGames , startDate : Date ( ) , groupStageLoserBracket : false , loserBracketMode : . manual )
let round = Round ( tournament : tournamentId , index : 1 , parent : parentRoundId , matchFormat : MatchFormat . nineGames , startDate : Date ( ) , groupStageLoserBracket : false , loserBracketMode : . manual )
round . storeId = " abc "
let r : Round = try await StoreCenter . main . service ( ) . post ( round )
let r : Round = try await StoreCenter . main . service ( ) . post ( round )
assert ( r . storeId = = round . storeId )
assert ( r . tournament = = round . tournament )
assert ( r . tournament = = round . tournament )
assert ( r . lastUpdate = = round . lastUpdate )
assert ( r . index = = round . index )
assert ( r . index = = round . index )
assert ( r . parent = = round . parent )
assert ( r . parent = = round . parent )
assert ( r . matchFormat = = round . matchFormat )
assert ( r . matchFormat = = round . matchFormat )
@ -201,10 +211,13 @@ final class ServerDataTests: XCTestCase {
}
}
let teamRegistration = TeamRegistration ( tournament : tournamentId , groupStage : groupStageId , registrationDate : Date ( ) , callDate : Date ( ) , bracketPosition : 1 , groupStagePosition : 2 , comment : " comment " , source : " source " , sourceValue : " source V " , logo : " logo " , name : " Stax " , walkOut : true , wildCardBracket : true , wildCardGroupStage : true , weight : 1 , lockedWeight : 11 , confirmationDate : Date ( ) , qualified : true )
let teamRegistration = TeamRegistration ( tournament : tournamentId , groupStage : groupStageId , registrationDate : Date ( ) , callDate : Date ( ) , bracketPosition : 1 , groupStagePosition : 2 , comment : " comment " , source : " source " , sourceValue : " source V " , logo : " logo " , name : " Stax " , walkOut : true , wildCardBracket : true , wildCardGroupStage : true , weight : 1 , lockedWeight : 11 , confirmationDate : Date ( ) , qualified : true )
teamRegistration . storeId = " 123 "
let tr : TeamRegistration = try await StoreCenter . main . service ( ) . post ( teamRegistration )
let tr : TeamRegistration = try await StoreCenter . main . service ( ) . post ( teamRegistration )
assert ( tr . storeId = = teamRegistration . storeId )
assert ( tr . tournament = = teamRegistration . tournament )
assert ( tr . tournament = = teamRegistration . tournament )
assert ( tr . lastUpdate = = teamRegistration . lastUpdate )
assert ( tr . groupStage = = teamRegistration . groupStage )
assert ( tr . groupStage = = teamRegistration . groupStage )
assert ( tr . registrationDate != nil )
assert ( tr . registrationDate != nil )
assert ( tr . callDate != nil )
assert ( tr . callDate != nil )
@ -234,8 +247,11 @@ final class ServerDataTests: XCTestCase {
}
}
let playerRegistration = PlayerRegistration ( teamRegistration : teamRegistrationId , firstName : " juan " , lastName : " lebron " , licenceId : " 123 " , rank : 11 , paymentType : PlayerRegistration . PlayerPaymentType . cash , sex : PlayerRegistration . PlayerSexType . male , tournamentPlayed : 2 , points : 33 , clubName : " le club " , ligueName : " la league " , assimilation : " ass " , phoneNumber : " 123123 " , email : " email@email.com " , birthdate : nil , computedRank : 222 , source : PlayerRegistration . PlayerDataSource . frenchFederation , hasArrived : true )
let playerRegistration = PlayerRegistration ( teamRegistration : teamRegistrationId , firstName : " juan " , lastName : " lebron " , licenceId : " 123 " , rank : 11 , paymentType : PlayerRegistration . PlayerPaymentType . cash , sex : PlayerRegistration . PlayerSexType . male , tournamentPlayed : 2 , points : 33 , clubName : " le club " , ligueName : " la league " , assimilation : " ass " , phoneNumber : " 123123 " , email : " email@email.com " , birthdate : nil , computedRank : 222 , source : PlayerRegistration . PlayerDataSource . frenchFederation , hasArrived : true )
playerRegistration . storeId = " 123 "
let pr : PlayerRegistration = try await StoreCenter . main . service ( ) . post ( playerRegistration )
let pr : PlayerRegistration = try await StoreCenter . main . service ( ) . post ( playerRegistration )
assert ( pr . storeId = = playerRegistration . storeId )
assert ( pr . lastName = = playerRegistration . lastName )
assert ( pr . teamRegistration = = playerRegistration . teamRegistration )
assert ( pr . teamRegistration = = playerRegistration . teamRegistration )
assert ( pr . firstName = = playerRegistration . firstName )
assert ( pr . firstName = = playerRegistration . firstName )
assert ( pr . lastName = = playerRegistration . lastName )
assert ( pr . lastName = = playerRegistration . lastName )
@ -267,8 +283,11 @@ final class ServerDataTests: XCTestCase {
let parentRoundId = rounds . first ? . id
let parentRoundId = rounds . first ? . id
let match : Match = Match ( round : parentRoundId , groupStage : nil , startDate : Date ( ) , endDate : Date ( ) , index : 2 , matchFormat : MatchFormat . twoSets , servingTeamId : teamRegistrationId , winningTeamId : teamRegistrationId , losingTeamId : teamRegistrationId , disabled : true , courtIndex : 1 , confirmed : true )
let match : Match = Match ( round : parentRoundId , groupStage : nil , startDate : Date ( ) , endDate : Date ( ) , index : 2 , matchFormat : MatchFormat . twoSets , servingTeamId : teamRegistrationId , winningTeamId : teamRegistrationId , losingTeamId : teamRegistrationId , disabled : true , courtIndex : 1 , confirmed : true )
match . storeId = " 123 "
let m : Match = try await StoreCenter . main . service ( ) . post ( match )
let m : Match = try await StoreCenter . main . service ( ) . post ( match )
assert ( m . storeId = = match . storeId )
assert ( m . lastUpdate = = match . lastUpdate )
assert ( m . round = = match . round )
assert ( m . round = = match . round )
assert ( m . groupStage = = match . groupStage )
assert ( m . groupStage = = match . groupStage )
assert ( m . startDate != nil )
assert ( m . startDate != nil )
@ -297,8 +316,11 @@ final class ServerDataTests: XCTestCase {
return
return
}
}
let teamScore = TeamScore ( match : matchId , teamRegistration : teamRegistrationId , score : " 6/6 " , walkOut : 1 , luckyLoser : 1 )
let teamScore = TeamScore ( match : matchId , teamRegistration : teamRegistrationId , score : " 6/6 " , walkOut : 1 , luckyLoser : 1 )
teamScore . storeId = " !23 "
let ts : TeamScore = try await StoreCenter . main . service ( ) . post ( teamScore )
let ts : TeamScore = try await StoreCenter . main . service ( ) . post ( teamScore )
assert ( ts . storeId = = teamScore . storeId )
assert ( ts . lastUpdate = = teamScore . lastUpdate )
assert ( ts . match = = teamScore . match )
assert ( ts . match = = teamScore . match )
assert ( ts . teamRegistration = = teamScore . teamRegistration )
assert ( ts . teamRegistration = = teamScore . teamRegistration )
assert ( ts . score = = teamScore . score )
assert ( ts . score = = teamScore . score )
@ -318,6 +340,7 @@ final class ServerDataTests: XCTestCase {
let court = Court ( index : 1 , club : clubId , name : " Philippe Chatrier " , exitAllowed : true , indoor : true )
let court = Court ( index : 1 , club : clubId , name : " Philippe Chatrier " , exitAllowed : true , indoor : true )
let c : Court = try await StoreCenter . main . service ( ) . post ( court )
let c : Court = try await StoreCenter . main . service ( ) . post ( court )
assert ( c . lastUpdate = = court . lastUpdate )
assert ( c . club = = court . club )
assert ( c . club = = court . club )
assert ( c . name = = court . name )
assert ( c . name = = court . name )
assert ( c . index = = court . index )
assert ( c . index = = court . index )
@ -337,6 +360,7 @@ final class ServerDataTests: XCTestCase {
let dateInterval = DateInterval ( event : eventId , courtIndex : 1 , startDate : Date ( ) , endDate : Date ( ) )
let dateInterval = DateInterval ( event : eventId , courtIndex : 1 , startDate : Date ( ) , endDate : Date ( ) )
let di : PadelClub . DateInterval = try await StoreCenter . main . service ( ) . post ( dateInterval )
let di : PadelClub . DateInterval = try await StoreCenter . main . service ( ) . post ( dateInterval )
assert ( di . lastUpdate = = dateInterval . lastUpdate )
assert ( di . event = = dateInterval . event )
assert ( di . event = = dateInterval . event )
assert ( di . courtIndex = = dateInterval . courtIndex )
assert ( di . courtIndex = = dateInterval . courtIndex )
assert ( di . startDate . formatted ( ) = = dateInterval . startDate . formatted ( ) )
assert ( di . startDate . formatted ( ) = = dateInterval . startDate . formatted ( ) )
@ -354,10 +378,12 @@ final class ServerDataTests: XCTestCase {
let transactionId = UInt64 . random ( in : 0. . . 100000 )
let transactionId = UInt64 . random ( in : 0. . . 100000 )
let quantity = Int . random ( in : 0. . . 10 )
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 , purchaseDate : Date ( ) , productId : " app.padelclub.productId " , quantity : quantity , revocationDate : Date ( ) , expirationDate : Date ( ) )
let p : Purchase = try await StoreCenter . main . service ( ) . post ( purchase )
let p : Purchase = try await StoreCenter . main . service ( ) . post ( purchase )
assert ( p . id = = purchase . id )
assert ( p . id = = purchase . id )
assert ( p . lastUpdate = = purchase . lastUpdate )
assert ( p . user = = purchase . user )
assert ( p . user = = purchase . user )
assert ( p . productId = = purchase . productId )
assert ( p . productId = = purchase . productId )
assert ( p . purchaseDate . formatted ( ) = = purchase . purchaseDate . formatted ( ) )
assert ( p . purchaseDate . formatted ( ) = = purchase . purchaseDate . formatted ( ) )