3 Commits

Author SHA1 Message Date
32f3f68da9 Annotation for missing test & method
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m1s
Pull Request Pipeline / lint (pull_request) Successful in 2m4s
2025-11-21 12:46:18 +01:00
229750ffcf Fixed test 2025-11-21 12:46:04 +01:00
fe9239ee02 Added missing test 2025-11-21 12:45:48 +01:00
4 changed files with 28 additions and 4 deletions

View File

@@ -10,6 +10,9 @@ class PlayerGroupDao extends DatabaseAccessor<AppDatabase>
with _$PlayerGroupDaoMixin {
PlayerGroupDao(super.db);
/// No need for a groupHasPlayers method since the members attribute is
/// not nullable
/// Adds a [player] to a group with the given [groupId].
/// If the player is already in the group, no action is taken.
/// If the player does not exist in the player table, they are added.

View File

@@ -104,7 +104,25 @@ void main() {
expect(result.group, null);
});
// TODO: test getGroupOfGame()
test('Retrieving group of a game works correctly', () async {});
test('Retrieving group of a game works correctly', () async {
await database.gameDao.addGame(game: gameWithGroup);
final group = await database.groupGameDao.getGroupOfGame(
gameId: gameWithGroup.id,
);
if (group == null) {
fail('Group should not be null');
}
expect(group.id, testgroup.id);
expect(group.name, testgroup.name);
expect(group.createdAt, testgroup.createdAt);
expect(group.members.length, testgroup.members.length);
for (int i = 0; i < group.members.length; i++) {
expect(group.members[i].id, testgroup.members[i].id);
expect(group.members[i].name, testgroup.members[i].name);
expect(group.members[i].createdAt, testgroup.members[i].createdAt);
}
});
});
}

View File

@@ -110,9 +110,9 @@ void main() {
expect(removed, true);
final result = await database.gameDao.getGameById(
gameId: testgameWithGroup.id,
gameId: testgameWithPlayers.id,
);
expect(result.players!.length, testgameWithGroup.players!.length - 1);
expect(result.players!.length, testgameWithPlayers.players!.length - 1);
final playerExists = result.players!.any(
(p) => p.id == playerToRemove.id,

View File

@@ -41,6 +41,9 @@ void main() {
});
group('Player-Group Tests', () {
/// No need to test if group has players since the members attribute is
/// not nullable
test('Adding a player to a group works correctly', () async {
await database.groupDao.addGroup(group: testgroup);
await database.playerDao.addPlayer(player: player4);