integration tests
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m50s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m50s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
This commit is contained in:
@@ -3,10 +3,23 @@ import {
|
||||
DashboardAccessedEvent,
|
||||
DashboardErrorEvent,
|
||||
} from '../../core/dashboard/application/ports/DashboardEventPublisher';
|
||||
import {
|
||||
LeagueEventPublisher,
|
||||
LeagueCreatedEvent,
|
||||
LeagueUpdatedEvent,
|
||||
LeagueDeletedEvent,
|
||||
LeagueAccessedEvent,
|
||||
LeagueRosterAccessedEvent,
|
||||
} from '../../core/leagues/application/ports/LeagueEventPublisher';
|
||||
|
||||
export class InMemoryEventPublisher implements DashboardEventPublisher {
|
||||
export class InMemoryEventPublisher implements DashboardEventPublisher, LeagueEventPublisher {
|
||||
private dashboardAccessedEvents: DashboardAccessedEvent[] = [];
|
||||
private dashboardErrorEvents: DashboardErrorEvent[] = [];
|
||||
private leagueCreatedEvents: LeagueCreatedEvent[] = [];
|
||||
private leagueUpdatedEvents: LeagueUpdatedEvent[] = [];
|
||||
private leagueDeletedEvents: LeagueDeletedEvent[] = [];
|
||||
private leagueAccessedEvents: LeagueAccessedEvent[] = [];
|
||||
private leagueRosterAccessedEvents: LeagueRosterAccessedEvent[] = [];
|
||||
private shouldFail: boolean = false;
|
||||
|
||||
async publishDashboardAccessed(event: DashboardAccessedEvent): Promise<void> {
|
||||
@@ -19,6 +32,31 @@ export class InMemoryEventPublisher implements DashboardEventPublisher {
|
||||
this.dashboardErrorEvents.push(event);
|
||||
}
|
||||
|
||||
async emitLeagueCreated(event: LeagueCreatedEvent): Promise<void> {
|
||||
if (this.shouldFail) throw new Error('Event publisher failed');
|
||||
this.leagueCreatedEvents.push(event);
|
||||
}
|
||||
|
||||
async emitLeagueUpdated(event: LeagueUpdatedEvent): Promise<void> {
|
||||
if (this.shouldFail) throw new Error('Event publisher failed');
|
||||
this.leagueUpdatedEvents.push(event);
|
||||
}
|
||||
|
||||
async emitLeagueDeleted(event: LeagueDeletedEvent): Promise<void> {
|
||||
if (this.shouldFail) throw new Error('Event publisher failed');
|
||||
this.leagueDeletedEvents.push(event);
|
||||
}
|
||||
|
||||
async emitLeagueAccessed(event: LeagueAccessedEvent): Promise<void> {
|
||||
if (this.shouldFail) throw new Error('Event publisher failed');
|
||||
this.leagueAccessedEvents.push(event);
|
||||
}
|
||||
|
||||
async emitLeagueRosterAccessed(event: LeagueRosterAccessedEvent): Promise<void> {
|
||||
if (this.shouldFail) throw new Error('Event publisher failed');
|
||||
this.leagueRosterAccessedEvents.push(event);
|
||||
}
|
||||
|
||||
getDashboardAccessedEventCount(): number {
|
||||
return this.dashboardAccessedEvents.length;
|
||||
}
|
||||
@@ -27,9 +65,38 @@ export class InMemoryEventPublisher implements DashboardEventPublisher {
|
||||
return this.dashboardErrorEvents.length;
|
||||
}
|
||||
|
||||
getLeagueCreatedEventCount(): number {
|
||||
return this.leagueCreatedEvents.length;
|
||||
}
|
||||
|
||||
getLeagueUpdatedEventCount(): number {
|
||||
return this.leagueUpdatedEvents.length;
|
||||
}
|
||||
|
||||
getLeagueDeletedEventCount(): number {
|
||||
return this.leagueDeletedEvents.length;
|
||||
}
|
||||
|
||||
getLeagueAccessedEventCount(): number {
|
||||
return this.leagueAccessedEvents.length;
|
||||
}
|
||||
|
||||
getLeagueRosterAccessedEventCount(): number {
|
||||
return this.leagueRosterAccessedEvents.length;
|
||||
}
|
||||
|
||||
getLeagueRosterAccessedEvents(): LeagueRosterAccessedEvent[] {
|
||||
return [...this.leagueRosterAccessedEvents];
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
this.dashboardAccessedEvents = [];
|
||||
this.dashboardErrorEvents = [];
|
||||
this.leagueCreatedEvents = [];
|
||||
this.leagueUpdatedEvents = [];
|
||||
this.leagueDeletedEvents = [];
|
||||
this.leagueAccessedEvents = [];
|
||||
this.leagueRosterAccessedEvents = [];
|
||||
this.shouldFail = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
LeagueUpdatedEvent,
|
||||
LeagueDeletedEvent,
|
||||
LeagueAccessedEvent,
|
||||
LeagueRosterAccessedEvent,
|
||||
} from '../../../core/leagues/application/ports/LeagueEventPublisher';
|
||||
|
||||
export class InMemoryLeagueEventPublisher implements LeagueEventPublisher {
|
||||
@@ -11,6 +12,7 @@ export class InMemoryLeagueEventPublisher implements LeagueEventPublisher {
|
||||
private leagueUpdatedEvents: LeagueUpdatedEvent[] = [];
|
||||
private leagueDeletedEvents: LeagueDeletedEvent[] = [];
|
||||
private leagueAccessedEvents: LeagueAccessedEvent[] = [];
|
||||
private leagueRosterAccessedEvents: LeagueRosterAccessedEvent[] = [];
|
||||
|
||||
async emitLeagueCreated(event: LeagueCreatedEvent): Promise<void> {
|
||||
this.leagueCreatedEvents.push(event);
|
||||
@@ -28,6 +30,10 @@ export class InMemoryLeagueEventPublisher implements LeagueEventPublisher {
|
||||
this.leagueAccessedEvents.push(event);
|
||||
}
|
||||
|
||||
async emitLeagueRosterAccessed(event: LeagueRosterAccessedEvent): Promise<void> {
|
||||
this.leagueRosterAccessedEvents.push(event);
|
||||
}
|
||||
|
||||
getLeagueCreatedEventCount(): number {
|
||||
return this.leagueCreatedEvents.length;
|
||||
}
|
||||
@@ -44,11 +50,16 @@ export class InMemoryLeagueEventPublisher implements LeagueEventPublisher {
|
||||
return this.leagueAccessedEvents.length;
|
||||
}
|
||||
|
||||
getLeagueRosterAccessedEventCount(): number {
|
||||
return this.leagueRosterAccessedEvents.length;
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
this.leagueCreatedEvents = [];
|
||||
this.leagueUpdatedEvents = [];
|
||||
this.leagueDeletedEvents = [];
|
||||
this.leagueAccessedEvents = [];
|
||||
this.leagueRosterAccessedEvents = [];
|
||||
}
|
||||
|
||||
getLeagueCreatedEvents(): LeagueCreatedEvent[] {
|
||||
@@ -66,4 +77,8 @@ export class InMemoryLeagueEventPublisher implements LeagueEventPublisher {
|
||||
getLeagueAccessedEvents(): LeagueAccessedEvent[] {
|
||||
return [...this.leagueAccessedEvents];
|
||||
}
|
||||
|
||||
getLeagueRosterAccessedEvents(): LeagueRosterAccessedEvent[] {
|
||||
return [...this.leagueRosterAccessedEvents];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,10 @@ import {
|
||||
LeagueResolutionTimeMetrics,
|
||||
LeagueComplexSuccessRateMetrics,
|
||||
LeagueComplexResolutionTimeMetrics,
|
||||
LeagueMember,
|
||||
LeaguePendingRequest,
|
||||
} from '../../../../core/leagues/application/ports/LeagueRepository';
|
||||
import { LeagueStandingData } from '../../../../core/dashboard/application/ports/DashboardRepository';
|
||||
|
||||
export class InMemoryLeagueRepository implements LeagueRepository {
|
||||
private leagues: Map<string, LeagueData> = new Map();
|
||||
@@ -25,6 +28,9 @@ export class InMemoryLeagueRepository implements LeagueRepository {
|
||||
private leagueResolutionTimeMetrics: Map<string, LeagueResolutionTimeMetrics> = new Map();
|
||||
private leagueComplexSuccessRateMetrics: Map<string, LeagueComplexSuccessRateMetrics> = new Map();
|
||||
private leagueComplexResolutionTimeMetrics: Map<string, LeagueComplexResolutionTimeMetrics> = new Map();
|
||||
private leagueStandings: Map<string, LeagueStandingData[]> = new Map();
|
||||
private leagueMembers: Map<string, LeagueMember[]> = new Map();
|
||||
private leaguePendingRequests: Map<string, LeaguePendingRequest[]> = new Map();
|
||||
|
||||
async create(league: LeagueData): Promise<LeagueData> {
|
||||
this.leagues.set(league.id, league);
|
||||
@@ -194,6 +200,33 @@ export class InMemoryLeagueRepository implements LeagueRepository {
|
||||
this.leagueResolutionTimeMetrics.clear();
|
||||
this.leagueComplexSuccessRateMetrics.clear();
|
||||
this.leagueComplexResolutionTimeMetrics.clear();
|
||||
this.leagueStandings.clear();
|
||||
this.leagueMembers.clear();
|
||||
this.leaguePendingRequests.clear();
|
||||
}
|
||||
|
||||
addLeagueStandings(driverId: string, standings: LeagueStandingData[]): void {
|
||||
this.leagueStandings.set(driverId, standings);
|
||||
}
|
||||
|
||||
async getLeagueStandings(driverId: string): Promise<LeagueStandingData[]> {
|
||||
return this.leagueStandings.get(driverId) || [];
|
||||
}
|
||||
|
||||
addLeagueMembers(leagueId: string, members: LeagueMember[]): void {
|
||||
this.leagueMembers.set(leagueId, members);
|
||||
}
|
||||
|
||||
async getLeagueMembers(leagueId: string): Promise<LeagueMember[]> {
|
||||
return this.leagueMembers.get(leagueId) || [];
|
||||
}
|
||||
|
||||
addPendingRequests(leagueId: string, requests: LeaguePendingRequest[]): void {
|
||||
this.leaguePendingRequests.set(leagueId, requests);
|
||||
}
|
||||
|
||||
async getPendingRequests(leagueId: string): Promise<LeaguePendingRequest[]> {
|
||||
return this.leaguePendingRequests.get(leagueId) || [];
|
||||
}
|
||||
|
||||
private createDefaultStats(leagueId: string): LeagueStats {
|
||||
|
||||
Reference in New Issue
Block a user