Updating writethrough test to be aware of the double attempt locks.
This commit is contained in:
parent
7c7bd4d5cb
commit
5249148d6c
|
@ -72,20 +72,26 @@ describe("writethrough", () => {
|
||||||
writethrough.put({ ...current, value: 4 }),
|
writethrough.put({ ...current, value: 4 }),
|
||||||
])
|
])
|
||||||
|
|
||||||
const newRev = responses.map(x => x.rev).find(x => x !== current._rev)
|
// with a lock, this will work
|
||||||
expect(newRev).toBeDefined()
|
const revs = responses.map(x => x.rev)
|
||||||
expect(responses.map(x => x.rev)).toEqual(
|
const startWith = ["3", "4", "5"]
|
||||||
expect.arrayContaining([current._rev, current._rev, newRev])
|
const found = []
|
||||||
)
|
let maxRev
|
||||||
expectFunctionWasCalledTimesWith(
|
for (let starting of startWith) {
|
||||||
mocks.alerts.logWarn,
|
for (let rev of revs) {
|
||||||
2,
|
if (rev?.startsWith(starting)) {
|
||||||
"Ignoring redlock conflict in write-through cache"
|
found.push(starting)
|
||||||
)
|
}
|
||||||
|
if (rev?.startsWith("5")) {
|
||||||
|
maxRev = rev
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect(found.length).toBe(3)
|
||||||
|
|
||||||
const output = await db.get(current._id)
|
const output = await db.get(current._id)
|
||||||
expect(output.value).toBe(4)
|
expect(output.value).toBe(4)
|
||||||
expect(output._rev).toBe(newRev)
|
expect(output._rev).toBe(maxRev)
|
||||||
|
|
||||||
current = output
|
current = output
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue