This commit is contained in:
2025-12-17 12:05:00 +01:00
parent 4d890863d3
commit 07dfefebe4
65 changed files with 6034 additions and 778 deletions

View File

@@ -4,7 +4,7 @@
* Mock repository for testing and development
*/
import type { SeasonSponsorship, SponsorshipTier } from '@core/racing/domain/entities/SeasonSponsorship';
import type { SeasonSponsorship, SponsorshipTier } from '@core/racing/domain/entities/season/SeasonSponsorship';
import type { ISeasonSponsorshipRepository } from '@core/racing/domain/repositories/ISeasonSponsorshipRepository';
import type { Logger } from '@core/shared/application';
@@ -12,12 +12,9 @@ export class InMemorySeasonSponsorshipRepository implements ISeasonSponsorshipRe
private sponsorships: Map<string, SeasonSponsorship> = new Map();
private readonly logger: Logger;
constructor(logger: Logger, seedData?: SeasonSponsorship[]) {
constructor(logger: Logger) {
this.logger = logger;
this.logger.info('InMemorySeasonSponsorshipRepository initialized.');
if (seedData) {
this.seed(seedData);
}
}
async findById(id: string): Promise<SeasonSponsorship | null> {
@@ -81,7 +78,7 @@ export class InMemorySeasonSponsorshipRepository implements ISeasonSponsorshipRe
this.logger.info(`Found ${sponsorships.length} season sponsorships for season id: ${seasonId}, tier: ${tier}.`);
return sponsorships;
} catch (error) {
this.logger.error(`Error finding season sponsorships by season id ${seasonId}, tier ${tier}:`, error);
this.logger.error(`Error finding season sponsorships by season id ${seasonId}, tier ${tier}:`, error instanceof Error ? error : new Error(String(error)));
throw error;
}
}
@@ -144,22 +141,6 @@ export class InMemorySeasonSponsorshipRepository implements ISeasonSponsorshipRe
}
}
/**
* Seed initial data
*/
seed(sponsorships: SeasonSponsorship[]): void {
this.logger.debug(`Seeding ${sponsorships.length} season sponsorships.`);
try {
for (const sponsorship of sponsorships) {
this.sponsorships.set(sponsorship.id, sponsorship);
this.logger.debug(`Seeded season sponsorship: ${sponsorship.id}.`);
}
this.logger.info(`Successfully seeded ${sponsorships.length} season sponsorships.`);
} catch (error) {
this.logger.error(`Error seeding season sponsorships:`, error instanceof Error ? error : new Error(String(error)));
throw error;
}
}
// Test helper
clear(): void {