testDeleteOperation function
Implementation
Future<void> testDeleteOperation(FirestoreApp apiProvider) async {
String competitionId = 'comp_2'; // Example for one competition
String matchId = 'UJzdR6ozKzKq8R2SZ5eh';
String eventId = 'BG0yxqMGcT7KzJDvwo9l';
String eventPath =
'sports/soccer/competitions/$competitionId/matches/$matchId/events/$eventId';
// Verify the event exists before deletion
dynamic beforeDeleteSnapshot = await apiProvider.performGetOperation({
'path':
'sports/soccer/competitions/$competitionId/matches/$matchId/events/$eventId'
});
if (beforeDeleteSnapshot == null ||
!(beforeDeleteSnapshot as DocumentSnapshot).exists) {
print('Event already does not exist.');
return;
}
// Perform the delete operation
await apiProvider.performDeleteOperation({'path': eventPath});
// Verify the event does not exist after deletion
dynamic afterDeleteSnapshot = await apiProvider.performGetOperation({
'path':
'sports/soccer/competitions/$competitionId/matches/$matchId/events/$eventId',
});
// Validation
if (afterDeleteSnapshot == null ||
!(afterDeleteSnapshot as DocumentSnapshot).exists) {
print('Delete validation successful.');
} else {
print('Delete validation failed.');
}
}