fix: guard competition stats rebuild revisions
This commit is contained in:
1 parent
ee4c3eeb27
commit
4d6fa2625e
2 files changed
+60
-3
No files matched your search
@@ -206,7 +206,7 @@ describe('MatchStatsService', () => {
|
||||
{ getMatchTimeline: jest.fn() } as never,
|
||||
);
|
||||
|
||||
await service.buildAndUpsert(matchId);
|
||||
await service.buildAndUpsert(matchId, { sourceRevision: 12 });
|
||||
|
||||
expect(riotFind).toHaveBeenCalledWith({
|
||||
matchId: { $in: ['KR_COMPETITION'] },
|
||||
@@ -236,6 +236,54 @@ describe('MatchStatsService', () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('does not rebuild before the requested Competition revision is visible', async () => {
|
||||
const matchId = new mongoose.Types.ObjectId();
|
||||
const riotFind = jest.fn();
|
||||
const connectionService = {
|
||||
getModel: jest.fn().mockImplementation(async (name: string) => {
|
||||
if (name === 'match') {
|
||||
return {
|
||||
findById: () =>
|
||||
queryResult(
|
||||
{
|
||||
_id: matchId,
|
||||
status: 'in-progress',
|
||||
},
|
||||
false,
|
||||
),
|
||||
};
|
||||
}
|
||||
if (name === 'competition') {
|
||||
return {
|
||||
findOne: () => queryResult({ revision: 11 }),
|
||||
};
|
||||
}
|
||||
if (name === 'riotMatch') return { find: riotFind };
|
||||
throw new Error(`Unexpected model: ${name}`);
|
||||
}),
|
||||
} as unknown as ConnectionService;
|
||||
const repository = {
|
||||
upsert: jest.fn(),
|
||||
deleteByMatch: jest.fn(),
|
||||
} as unknown as jest.Mocked<MatchStatsRepository>;
|
||||
const builder = {
|
||||
buildFragment: jest.fn(),
|
||||
} as unknown as jest.Mocked<MatchStatsFragmentBuilder>;
|
||||
const service = new MatchStatsService(
|
||||
connectionService,
|
||||
repository,
|
||||
builder,
|
||||
{ getMatchTimeline: jest.fn() } as never,
|
||||
);
|
||||
|
||||
await service.buildAndUpsert(matchId, { sourceRevision: 12 });
|
||||
|
||||
expect(riotFind).not.toHaveBeenCalled();
|
||||
expect(builder.buildFragment).not.toHaveBeenCalled();
|
||||
expect(repository.upsert).not.toHaveBeenCalled();
|
||||
expect(repository.deleteByMatch).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
function participant(
|
||||
|
||||
Reference in new issue
Block a user