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:
@@ -6,34 +6,33 @@ import type { Payment, PaymentType } from '@core/payments/domain/entities/Paymen
|
||||
import type { PaymentRepository } from '@core/payments/domain/repositories/PaymentRepository';
|
||||
import type { Logger } from '@core/shared/domain/Logger';
|
||||
|
||||
const payments: Map<string, Payment> = new Map();
|
||||
|
||||
export class InMemoryPaymentRepository implements PaymentRepository {
|
||||
private payments: Map<string, Payment> = new Map();
|
||||
constructor(private readonly logger: Logger) {}
|
||||
|
||||
async findById(id: string): Promise<Payment | null> {
|
||||
this.logger.debug('[InMemoryPaymentRepository] findById', { id });
|
||||
return payments.get(id) || null;
|
||||
return this.payments.get(id) || null;
|
||||
}
|
||||
|
||||
async findByLeagueId(leagueId: string): Promise<Payment[]> {
|
||||
this.logger.debug('[InMemoryPaymentRepository] findByLeagueId', { leagueId });
|
||||
return Array.from(payments.values()).filter(p => p.leagueId === leagueId);
|
||||
return Array.from(this.payments.values()).filter(p => p.leagueId === leagueId);
|
||||
}
|
||||
|
||||
async findByPayerId(payerId: string): Promise<Payment[]> {
|
||||
this.logger.debug('[InMemoryPaymentRepository] findByPayerId', { payerId });
|
||||
return Array.from(payments.values()).filter(p => p.payerId === payerId);
|
||||
return Array.from(this.payments.values()).filter(p => p.payerId === payerId);
|
||||
}
|
||||
|
||||
async findByType(type: PaymentType): Promise<Payment[]> {
|
||||
this.logger.debug('[InMemoryPaymentRepository] findByType', { type });
|
||||
return Array.from(payments.values()).filter(p => p.type === type);
|
||||
return Array.from(this.payments.values()).filter(p => p.type === type);
|
||||
}
|
||||
|
||||
async findByFilters(filters: { leagueId?: string; payerId?: string; type?: PaymentType }): Promise<Payment[]> {
|
||||
this.logger.debug('[InMemoryPaymentRepository] findByFilters', { filters });
|
||||
let results = Array.from(payments.values());
|
||||
let results = Array.from(this.payments.values());
|
||||
|
||||
if (filters.leagueId) {
|
||||
results = results.filter(p => p.leagueId === filters.leagueId);
|
||||
@@ -50,13 +49,17 @@ export class InMemoryPaymentRepository implements PaymentRepository {
|
||||
|
||||
async create(payment: Payment): Promise<Payment> {
|
||||
this.logger.debug('[InMemoryPaymentRepository] create', { payment });
|
||||
payments.set(payment.id, payment);
|
||||
this.payments.set(payment.id, payment);
|
||||
return payment;
|
||||
}
|
||||
|
||||
async update(payment: Payment): Promise<Payment> {
|
||||
this.logger.debug('[InMemoryPaymentRepository] update', { payment });
|
||||
payments.set(payment.id, payment);
|
||||
this.payments.set(payment.id, payment);
|
||||
return payment;
|
||||
}
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
this.payments.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user