remove winner tests
Some checks failed
Pull Request Pipeline / test (pull_request) Failing after 2m2s
Pull Request Pipeline / lint (pull_request) Successful in 2m15s

This commit is contained in:
gelbeinhalb
2026-01-20 16:03:37 +01:00
parent e09ccf9356
commit b108375ad5

View File

@@ -278,86 +278,6 @@ void main() {
expect(matchCount, 0);
});
// Verifies that hasWinner correctly identifies matches with and without winners.
test('Checking if match has winner works correctly', () async {
await database.matchDao.addMatch(match: testMatch1);
await database.matchDao.addMatch(match: testMatchOnlyGroup);
var hasWinner = await database.matchDao.hasWinner(matchId: testMatch1.id);
expect(hasWinner, true);
hasWinner = await database.matchDao.hasWinner(
matchId: testMatchOnlyGroup.id,
);
expect(hasWinner, false);
});
// Verifies that getWinner returns the correct winner player for a match.
test('Fetching the winner of a match works correctly', () async {
await database.matchDao.addMatch(match: testMatch1);
final winner = await database.matchDao.getWinner(matchId: testMatch1.id);
if (winner == null) {
fail('Winner is null');
} else {
expect(winner.id, testMatch1.winner!.id);
expect(winner.name, testMatch1.winner!.name);
expect(winner.createdAt, testMatch1.winner!.createdAt);
}
});
// Verifies that setWinner correctly updates the winner of a match.
test('Updating the winner of a match works correctly', () async {
await database.matchDao.addMatch(match: testMatch1);
final winner = await database.matchDao.getWinner(matchId: testMatch1.id);
if (winner == null) {
fail('Winner is null');
} else {
expect(winner.id, testMatch1.winner!.id);
expect(winner.name, testMatch1.winner!.name);
expect(winner.createdAt, testMatch1.winner!.createdAt);
expect(winner.id, testPlayer4.id);
expect(winner.id != testPlayer5.id, true);
}
await database.matchDao.setWinner(
matchId: testMatch1.id,
winnerId: testPlayer5.id,
);
final newWinner = await database.matchDao.getWinner(
matchId: testMatch1.id,
);
if (newWinner == null) {
fail('New winner is null');
} else {
expect(newWinner.id, testPlayer5.id);
expect(newWinner.name, testPlayer5.name);
expect(newWinner.createdAt, testPlayer5.createdAt);
}
});
// Verifies that removeWinner clears the winner and hasWinner returns false.
test('Removing a winner works correctly', () async {
await database.matchDao.addMatch(match: testMatch2);
var hasWinner = await database.matchDao.hasWinner(matchId: testMatch2.id);
expect(hasWinner, true);
await database.matchDao.removeWinner(matchId: testMatch2.id);
hasWinner = await database.matchDao.hasWinner(matchId: testMatch2.id);
expect(hasWinner, false);
final removedWinner = await database.matchDao.getWinner(
matchId: testMatch2.id,
);
expect(removedWinner, null);
});
// Verifies that updateMatchName correctly updates only the name field.
test('Renaming a match works correctly', () async {
await database.matchDao.addMatch(match: testMatch1);