Skip to content

Commit 5dcde1a

Browse files
committed
implement spec runner changes
1 parent 1ba24eb commit 5dcde1a

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

test/tools/unified-spec-runner/match.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
type Document,
2424
Long,
2525
MongoError,
26+
MongoOperationTimeoutError,
2627
MongoServerError,
2728
ObjectId,
2829
type OneOrMore,
@@ -96,6 +97,19 @@ export function isMatchAsRootOperator(value: unknown): value is MatchAsRootOpera
9697
return typeof value === 'object' && value != null && '$$matchAsRoot' in value;
9798
}
9899

100+
export interface LteOperator {
101+
$$lte: number;
102+
}
103+
104+
export function isLteOperator(value: unknown): value is LteOperator {
105+
return (
106+
typeof value === 'object' &&
107+
value != null &&
108+
'$$lte' in value &&
109+
typeof value['$$lte'] === 'number'
110+
);
111+
}
112+
99113
export const SpecialOperatorKeys = [
100114
'$$exists',
101115
'$$type',
@@ -104,7 +118,8 @@ export const SpecialOperatorKeys = [
104118
'$$matchAsRoot',
105119
'$$matchAsDocument',
106120
'$$unsetOrMatches',
107-
'$$sessionLsid'
121+
'$$sessionLsid',
122+
'$$lte'
108123
];
109124

110125
export type SpecialOperator =
@@ -115,7 +130,8 @@ export type SpecialOperator =
115130
| UnsetOrMatchesOperator
116131
| SessionLsidOperator
117132
| MatchAsDocumentOperator
118-
| MatchAsRootOperator;
133+
| MatchAsRootOperator
134+
| LteOperator;
119135

120136
type KeysOfUnion<T> = T extends object ? keyof T : never;
121137
export type SpecialOperatorKey = KeysOfUnion<SpecialOperator>;
@@ -128,7 +144,8 @@ export function isSpecialOperator(value: unknown): value is SpecialOperator {
128144
isUnsetOrMatchesOperator(value) ||
129145
isSessionLsidOperator(value) ||
130146
isMatchAsRootOperator(value) ||
131-
isMatchAsDocumentOperator(value)
147+
isMatchAsDocumentOperator(value) ||
148+
isLteOperator(value)
132149
);
133150
}
134151

@@ -377,6 +394,9 @@ export function specialCheck(
377394
);
378395

379396
resultCheck(actual, expected.$$matchAsRoot as any, entities, path, false);
397+
} else if (isLteOperator(expected)) {
398+
expect(typeof actual).to.equal('number');
399+
expect(actual).to.be.lte(expected.$$lte);
380400
} else {
381401
expect.fail(`Unknown special operator: ${JSON.stringify(expected)}`);
382402
}
@@ -736,6 +756,12 @@ export function expectErrorCheck(
736756
expect(error).not.to.be.instanceOf(MongoServerError);
737757
}
738758

759+
if (expected.isTimeoutError === false) {
760+
expect(error).to.not.be.instanceof(MongoOperationTimeoutError);
761+
} else if (expected.isTimeoutError === true) {
762+
expect(error).to.be.instanceof(MongoOperationTimeoutError);
763+
}
764+
739765
if (expected.errorContains != null) {
740766
expect(error.message.toLowerCase(), expectMessage.toLowerCase()).to.include(
741767
expected.errorContains.toLowerCase()

test/tools/unified-spec-runner/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ export interface StoreEventsAsEntity {
364364
}
365365
export interface ExpectedError {
366366
isError?: true;
367+
isTimeoutError?: boolean;
367368
isClientError?: boolean;
368369
errorContains?: string;
369370
errorCode?: number;

0 commit comments

Comments
 (0)