integration tests
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m51s
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 4m51s
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:
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* In-Memory Rating Repository
|
||||
*
|
||||
* In-memory implementation of RatingRepository for testing purposes.
|
||||
*/
|
||||
|
||||
import { RatingRepository } from '../../../../core/rating/ports/RatingRepository';
|
||||
import { Rating } from '../../../../core/rating/domain/Rating';
|
||||
|
||||
export class InMemoryRatingRepository implements RatingRepository {
|
||||
private ratings: Map<string, Rating> = new Map();
|
||||
|
||||
async save(rating: Rating): Promise<void> {
|
||||
const key = `${rating.driverId.toString()}-${rating.raceId.toString()}`;
|
||||
this.ratings.set(key, rating);
|
||||
}
|
||||
|
||||
async findByDriverAndRace(driverId: string, raceId: string): Promise<Rating | null> {
|
||||
const key = `${driverId}-${raceId}`;
|
||||
return this.ratings.get(key) || null;
|
||||
}
|
||||
|
||||
async findByDriver(driverId: string): Promise<Rating[]> {
|
||||
return Array.from(this.ratings.values()).filter(
|
||||
rating => rating.driverId.toString() === driverId
|
||||
);
|
||||
}
|
||||
|
||||
async findByRace(raceId: string): Promise<Rating[]> {
|
||||
return Array.from(this.ratings.values()).filter(
|
||||
rating => rating.raceId.toString() === raceId
|
||||
);
|
||||
}
|
||||
|
||||
async clear(): Promise<void> {
|
||||
this.ratings.clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user