feat: Deleting games associated with matches deletes them
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 42s
Pull Request Pipeline / lint (pull_request) Successful in 50s

This commit is contained in:
2026-05-03 01:00:44 +02:00
parent 92bf74683f
commit e3aef81ab6
11 changed files with 218 additions and 67 deletions

View File

@@ -366,5 +366,55 @@ void main() {
expect(match.group, isNotNull);
expect(match.group!.id, testGroup1.id);
});
test('getMatchCountByGame() works correctly', () async {
var count = await database.matchDao.getMatchCountByGame(
gameId: testGame.id,
);
expect(count, 0);
await database.matchDao.addMatch(match: testMatch1);
count = await database.matchDao.getMatchCountByGame(gameId: testGame.id);
expect(count, 1);
await database.matchDao.addMatch(match: testMatch2);
count = await database.matchDao.getMatchCountByGame(gameId: testGame.id);
expect(count, 2);
});
test('getMatchCountByGame() returns 0 for non-existent game', () async {
final count = await database.matchDao.getMatchCountByGame(
gameId: 'non-existent-game-id',
);
expect(count, 0);
});
test('deleteMatchesByGame() deletes all matches for a game', () async {
await database.matchDao.addMatch(match: testMatch1);
await database.matchDao.addMatch(match: testMatch2);
var count = await database.matchDao.getMatchCountByGame(
gameId: testGame.id,
);
expect(count, 2);
final deletedCount = await database.matchDao.deleteMatchesByGame(
gameId: testGame.id,
);
expect(deletedCount, 2);
count = await database.matchDao.getMatchCountByGame(gameId: testGame.id);
expect(count, 0);
final allMatches = await database.matchDao.getAllMatches();
expect(allMatches, isEmpty);
});
test('deleteMatchesByGame() returns 0 for non-existent game', () async {
final deletedCount = await database.matchDao.deleteMatchesByGame(
gameId: 'non-existent-game-id',
);
expect(deletedCount, 0);
});
});
}