fix tests to use observeChangesAsync version

This commit is contained in:
Nacho Codoñer
2024-02-21 17:57:04 +01:00
parent 7ae8141f16
commit 8d35ccffbf
3 changed files with 28 additions and 28 deletions

View File

@@ -700,7 +700,7 @@ _.each( [ 'MONGO', 'STRING'], function(idGeneration) {
},
});
const handle2 = await coll.find({ run }).observeChanges(
const handle2 = await coll.find({ run }).observeChangesAsync(
{
added: expectNotMutatable,
changed: function(id, o) {
@@ -2017,7 +2017,7 @@ _.each( [ 'MONGO', 'STRING'], function(idGeneration) {
let polls = {};
const handlesToStop = [];
const observe = async function(name, query) {
const handle = await coll.find(query).observeChanges({
const handle = await coll.find(query).observeChangesAsync({
// Make sure that we only poll on invalidation, not due to time, and
// keep track of when we do. Note: this option disables the use of
// oplogs (which admittedly is somewhat irrelevant to this feature).
@@ -3149,7 +3149,7 @@ if (Meteor.isServer) {
async function (test, expect) {
var self = this;
if (self.miniC) {
self.obs = await self.miniC.find().observeChanges({
self.obs = await self.miniC.find().observeChangesAsync({
added: async function (id, fields) {
self.events.push({evt: "a", id: id});
await Meteor._sleepForMs(200);
@@ -3476,13 +3476,13 @@ Meteor.isServer &&
if (MongoInternals.defaultRemoteCollectionDriver().mongo._oplogHandle) {
var observeWithOplog = await coll
.find({ x: 5 })
.observeChanges({ added: function() {} });
.observeChangesAsync({ added: function() {} });
test.isTrue(observeWithOplog._multiplexer._observeDriver._usesOplog);
await observeWithOplog.stop();
}
var observeWithoutOplog = await coll
.find({ x: 6 }, { _disableOplog: true })
.observeChanges({ added: function() {} });
.observeChangesAsync({ added: function() {} });
test.isFalse(observeWithoutOplog._multiplexer._observeDriver._usesOplog);
await observeWithoutOplog.stop();
});
@@ -3506,7 +3506,7 @@ Meteor.isServer &&
var output = [];
var handle = await coll
.find({ a: 1, b: 2 }, { fields: { c: 1 } })
.observeChanges({
.observeChangesAsync({
added: function(id, fields) {
output.push(['added', id, fields]);
},
@@ -3559,7 +3559,7 @@ Meteor.isServer &&
);
var changesOutput = [];
var changesHandle = await cursor.observeChanges({
var changesHandle = await cursor.observeChangesAsync({
added: function(id, fields) {
changesOutput.push(['added', fields]);
},
@@ -3604,7 +3604,7 @@ Meteor.isServer &&
var tmp;
var output = [];
var handle = await coll.find({ a: 'foo' }).observeChanges({
var handle = await coll.find({ a: 'foo' }).observeChangesAsync({
added: function(id, fields) {
output.push(['added', id, fields]);
},
@@ -3717,7 +3717,7 @@ testAsyncMulti('mongo-livedata - oplog - update EJSON', [
async function(test, expect) {
var self = this;
self.changes = [];
self.handle = await self.collection.find({}).observeChanges({
self.handle = await self.collection.find({}).observeChangesAsync({
added: function(id, fields) {
self.changes.push(['a', id, fields]);
},
@@ -3819,7 +3819,7 @@ Meteor.isServer &&
_.times(100, async function() {
await coll.insertAsync({ foo: 'baz' });
});
var handler = await coll.find({}).observeChanges({
var handler = await coll.find({}).observeChangesAsync({
added: async function(id) {
await coll.updateAsync(id, { $set: { foo: 'bar' } });
},
@@ -4050,7 +4050,7 @@ if (Meteor.isClient) {
futuresByNonce[nonce] = new Promise(r => (resolver = r));
var observe = await fenceOnBeforeFireErrorCollection
.find({ nonce: nonce })
.observeChanges({ added: function() {} });
.observeChangesAsync({ added: function() {} });
Meteor.setTimeout(async function() {
try {
await fenceOnBeforeFireErrorCollection.insertAsync({ nonce });
@@ -4214,7 +4214,7 @@ if (Meteor.isServer) {
resolve();
}
const observeHandle = await Collection.find().observeChanges({
const observeHandle = await Collection.find().observeChangesAsync({
async changed(id, fields) {
let expectedValue;

View File

@@ -25,7 +25,7 @@ _.each ([{added: 'added', forceOrdered: true},
var barid = await c.insertAsync({ thing: 'stuff' });
var fooid = await c.insertAsync({ noodles: 'good', bacon: 'bad', apples: 'ok' });
var handle = await c.find(fooid).observeChanges(logger);
var handle = await c.find(fooid).observeChangesAsync(logger);
if (added === 'added') {
await logger.expectResult(added, [
fooid,
@@ -60,7 +60,7 @@ _.each ([{added: 'added', forceOrdered: true},
const badCursor = c.find({}, { fields: { noodles: 1, _id: false } });
await test.throwsAsync(async function() {
await badCursor.observeChanges(logger);
await badCursor.observeChangesAsync(logger);
});
onComplete();
@@ -81,10 +81,10 @@ Tinytest.addAsync('observeChanges - callback isolation', async function(
async function(logger) {
var handles = [];
var cursor = c.find();
handles.push(await cursor.observeChanges(logger));
handles.push(await cursor.observeChangesAsync(logger));
// fields-tampering observer
handles.push(
await cursor.observeChanges({
await cursor.observeChangesAsync({
added: function(id, fields) {
fields.apples = 'green';
},
@@ -122,7 +122,7 @@ Tinytest.addAsync('observeChanges - single id - initial adds', async function(
Meteor.isServer,
async function(logger) {
var fooid = await c.insertAsync({ noodles: 'good', bacon: 'bad', apples: 'ok' });
var handle = await c.find(fooid).observeChanges(logger);
var handle = await c.find(fooid).observeChangesAsync(logger);
await logger.expectResult('added', [
fooid,
{ noodles: 'good', bacon: 'bad', apples: 'ok' },
@@ -148,7 +148,7 @@ Tinytest.addAsync('observeChanges - unordered - initial adds', async function(
async function(logger) {
var fooid = await c.insertAsync({ noodles: 'good', bacon: 'bad', apples: 'ok' });
var barid = await c.insertAsync({ noodles: 'good', bacon: 'weird', apples: 'ok' });
var handle = await c.find().observeChanges(logger);
var handle = await c.find().observeChangesAsync(logger);
await logger.expectResultUnordered([
{
callback: 'added',
@@ -176,7 +176,7 @@ Tinytest.addAsync('observeChanges - unordered - basics', async function(
['added', 'changed', 'removed'],
Meteor.isServer,
async function(logger) {
var handle = await c.find().observeChanges(logger);
var handle = await c.find().observeChangesAsync(logger);
var barid = await c.insertAsync({ thing: 'stuff' });
await logger.expectResultOnly('added', [barid, { thing: 'stuff' }]);
@@ -228,7 +228,7 @@ if (Meteor.isServer) {
async function(logger) {
var handle = await c
.find({}, { fields: { noodles: 1, bacon: 1 } })
.observeChanges(logger);
.observeChangesAsync(logger);
var barid = await c.insertAsync({ thing: 'stuff' });
await logger.expectResultOnly('added', [barid, {}]);
@@ -281,7 +281,7 @@ if (Meteor.isServer) {
{ mac: 1, cheese: 2 },
{ fields: { noodles: 1, bacon: 1, eggs: 1 } }
)
.observeChanges(logger);
.observeChangesAsync(logger);
var barid = await c.insertAsync({ thing: 'stuff', mac: 1, cheese: 2 });
await logger.expectResultOnly('added', [barid, {}]);
@@ -360,7 +360,7 @@ Tinytest.addAsync(
{ mac: 1, cheese: 2 },
{ fields: { noodles: 1, bacon: 1, eggs: 1 } }
)
.observeChanges(logger);
.observeChangesAsync(logger);
var fooid = await c.insertAsync({
noodles: 'good',
bacon: 'bad',
@@ -402,7 +402,7 @@ Tinytest.addAsync(
async function(logger) {
var handle = await c
.find({}, { fields: { 'type.name': 1 } })
.observeChanges(logger);
.observeChangesAsync(logger);
var id = await c.insertAsync({ type: { name: 'foobar' } });
await logger.expectResultOnly('added', [id, { type: { name: 'foobar' } }]);
@@ -428,7 +428,7 @@ Tinytest.addAsync(
['added', 'changed', 'removed'],
Meteor.isServer,
async function(logger) {
var handle = await c.find({ noodles: 'good' }).observeChanges(logger);
var handle = await c.find({ noodles: 'good' }).observeChangesAsync(logger);
var barid = await c.insertAsync({ thing: 'stuff' });
var fooid = await c.insertAsync({ noodles: 'good', bacon: 'bad', apples: 'ok' });
@@ -492,7 +492,7 @@ if (Meteor.isServer) {
self.expects.push(resolver);
var cursor = coll.find({ y: { $ne: 7 } }, { tailable: true });
self.handle = await cursor.observeChanges({
self.handle = await cursor.observeChangesAsync({
added: function(id, fields) {
self.xs.push(fields.x);
test.notEqual(self.expects.length, 0);
@@ -550,7 +550,7 @@ testAsyncMulti("observeChanges - bad query", [
var c = makeCollection();
var observeThrows = async function () {
await test.throwsAsync(async function () {
await c.find({__id: {$in: null}}).observeChanges({
await c.find({__id: {$in: null}}).observeChangesAsync({
added: function () {
test.fail("added shouldn't be called");
}
@@ -588,7 +588,7 @@ if (Meteor.isServer) {
await environmentVariable.withValue(true, async function() {
var handle = await c
.find({}, { fields: { 'type.name': 1 } })
.observeChanges({
.observeChangesAsync({
added: function() {
test.isTrue(environmentVariable.get());
handle.stop();

View File

@@ -63,7 +63,7 @@ steps.steppedDown = function () {
process.exit(0);
};
C.find().observeChanges({
C.find().observeChangesAsync({
added: function (id, fields) {
if (nextStepTimeout) {
Meteor.clearTimeout(nextStepTimeout);