Address PR review feedback (#3340)

Reset the pool forced-refusal mock Database sequence in native.reset() so later tests can still script the first construction as the checkpoint victim.
This commit is contained in:
Gergo Magyar 2026-09-21 11:44:55 +00:00
parent 3594528299
commit d2aea963a4

View file

@ -29,11 +29,13 @@ const { native } = vi.hoisted(() => {
/** Script the FIRST read-only Database (index 0) as the checkpoint victim. */
refuseFirst: true,
reset(options: { refuseFirst?: boolean } = {}) {
native.seq = 0;
native.calls.constructions = [];
native.calls.checkpoints = 0;
native.calls.refusalProbes = 0;
native.refuseFirst = options.refuseFirst ?? true;
},
seq: 0,
};
return { native };
});
@ -44,7 +46,6 @@ const { native } = vi.hoisted(() => {
// recovery open and the read-only retry must never refuse, or the recovery
// would kill itself.
vi.mock('@ladybugdb/core', () => {
let seq = 0;
class Database {
role: 'ro' | 'rw';
index: number;
@ -55,7 +56,7 @@ vi.mock('@ladybugdb/core', () => {
readOnly = false,
) {
this.role = readOnly ? 'ro' : 'rw';
this.index = seq++;
this.index = native.seq++;
native.calls.constructions.push(this.role);
}
async init(): Promise<void> {