feat: Deleting games associated with matches deletes them
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user