@ -96,7 +96,7 @@ final class ServerDataTests: XCTestCase {
return
return
}
}
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 )
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 : false )
let t = try await Store . main . service ( ) . post ( tournament )
let t = try await Store . main . service ( ) . post ( tournament )
assert ( t . event = = tournament . event )
assert ( t . event = = tournament . event )
@ -132,6 +132,7 @@ final class ServerDataTests: XCTestCase {
assert ( t . publishBrackets = = tournament . publishBrackets )
assert ( t . publishBrackets = = tournament . publishBrackets )
assert ( t . shouldVerifyBracket = = tournament . shouldVerifyBracket )
assert ( t . shouldVerifyBracket = = tournament . shouldVerifyBracket )
assert ( t . shouldVerifyGroupStage = = tournament . shouldVerifyGroupStage )
assert ( t . shouldVerifyGroupStage = = tournament . shouldVerifyGroupStage )
assert ( t . hideTeamsWeight = = tournament . hideTeamsWeight )
}
}
func testGroupStage ( ) async throws {
func testGroupStage ( ) async throws {
@ -254,7 +255,7 @@ final class ServerDataTests: XCTestCase {
let rounds : [ Round ] = try await Store . main . service ( ) . get ( )
let rounds : [ Round ] = try await Store . main . service ( ) . get ( )
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 )
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 m : Match = try await Store . main . service ( ) . post ( match )
let m : Match = try await Store . main . service ( ) . post ( match )
assert ( m . round = = match . round )
assert ( m . round = = match . round )
@ -268,6 +269,7 @@ final class ServerDataTests: XCTestCase {
assert ( m . losingTeamId = = match . losingTeamId )
assert ( m . losingTeamId = = match . losingTeamId )
assert ( m . disabled = = match . disabled )
assert ( m . disabled = = match . disabled )
assert ( m . courtIndex = = match . courtIndex )
assert ( m . courtIndex = = match . courtIndex )
assert ( m . confirmed = = match . confirmed )
}
}
@ -283,15 +285,11 @@ final class ServerDataTests: XCTestCase {
assertionFailure ( " missing teamRegistrations in database " )
assertionFailure ( " missing teamRegistrations in database " )
return
return
}
}
let playerRegistrations : [ PlayerRegistration ] = try await Store . main . service ( ) . get ( )
let teamScore = TeamScore ( match : matchId , teamRegistration : teamRegistrationId , score : " 6/6 " , walkOut : 1 , luckyLoser : 1 )
let regs = playerRegistrations . prefix ( upTo : 2 ) . map { $0 . id }
let teamScore = TeamScore ( match : matchId , teamRegistration : teamRegistrationId , playerRegistrations : regs , score : " 6/6 " , walkOut : 1 , luckyLoser : 1 )
let ts : TeamScore = try await Store . main . service ( ) . post ( teamScore )
let ts : TeamScore = try await Store . main . service ( ) . post ( teamScore )
assert ( ts . match = = teamScore . match )
assert ( ts . match = = teamScore . match )
assert ( ts . teamRegistration = = teamScore . teamRegistration )
assert ( ts . teamRegistration = = teamScore . teamRegistration )
assert ( ts . playerRegistrations = = teamScore . playerRegistrations )
assert ( ts . score = = teamScore . score )
assert ( ts . score = = teamScore . score )
assert ( ts . walkOut = = teamScore . walkOut )
assert ( ts . walkOut = = teamScore . walkOut )
assert ( ts . luckyLoser = = teamScore . luckyLoser )
assert ( ts . luckyLoser = = teamScore . luckyLoser )